pip 安装库时出现TypeError: expected str, bytes or os.PathLike object, not int
查看pip版本号
在Ubuntu端的anaconda创建新的虚拟环境,也不清楚哪边问题,在新创环境之后,查看已安装的库或者安装新的库时,就会出现以下报错
Exception:
Traceback (most recent call last):
File "/home/。。。/anaconda3/envs/torch/lib/python3.6/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/home/。。。/anaconda3/envs/torch/lib/python3.6/site-packages/pip/commands/install.py", line 272, in run
with self._build_session(options) as session:
File "/home/。。。/anaconda3/envs/torch/lib/python3.6/site-packages/pip/basecommand.py", line 69, in _build_session
if options.cache_dir else None
File "/home/。。。/anaconda3/envs/torch/lib/python3.6/posixpath.py", line 78, in join
a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not int
Traceback (most recent call last):
File "/home/。。。/anaconda3/envs/torch/bin/pip", line 6, in <module>
sys.exit(pip.main())
File "/home/。。。/anaconda3/envs/torch/lib/python3.6/site-packages/pip/__init__.py", line 249, in main
return command.main(cmd_args)
File "/home/。。。/anaconda3/envs/torch/lib/python3.6/site-packages/pip/basecommand.py", line 251, in main
timeout=min(5, options.timeout)) as session:
File "/home/。。。/anaconda3/envs/torch/lib/python3.6/site-packages/pip/basecommand.py", line 69, in _build_session
if options.cache_dir else None
File "/home/。。。/anaconda3/envs/torch/lib/python3.6/posixpath.py", line 78, in join
a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not int
然后看到网上资料,大部分都是说pip9.0的版本导致的会出这种问题,pip list查询我的环境,确实也是pip9.0的这个版本。
但是大部分的方法,我都尝试过了,让去更新pip,pip install --upgrade pip,但是这个命令,还是出现上面那个报错,pip还是没更新成功。
pip install --upgrade pip --no-cache-dir
我们 更新pip 不使用缓存,更新pip即可跳过报错,实现更新,解决问题!
pip list 查看库,无报错显示。