在使用 pip 安装软件时,报错如下
$ pip install numpy
Exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 290, in run
with self._build_session(options) as session:
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 69, in _build_session
if options.cache_dir else None
File "/usr/lib/python3.6/posixpath.py", line 80, in join
a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not int
解决方法是升级一下 pip 版本,并重新安装即可
$ curl https://bootstrap.pypa.io/get-pip.py | python -
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1892k 100 1892k 0 0 1958k 0 --:--:-- --:--:-- --:--:-- 1956k
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/, https://pypi.ngc.nvidia.com
Collecting pip
Downloading http://mirrors.aliyun.com/pypi/packages/cd/82/04e9aaf603fdbaecb4323b9e723f13c92c245f6ab2902195c53987848c78/pip-21.1.2-py3-none-any.whl (1.5 MB)
|████████████████████████████████| 1.5 MB 407 kB/s
Installing collected packages: pip
Successfully installed pip-21.1.2