Python3 3.6版 安装pip 出现错误 ModuleNotFoundError: No module named 'distutils.util'
如下链接的get-pip.py适合python 3.7以上:
$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
所以 python 3.6 使用如下链接:
$ curl https://bootstrap.pypa.io/pip/3.6/get-pip.py -o get-pip.py
$ python3 get-pip.py
如上安装会出现错误提示:
ex# python3 get-pip.py
Traceback (most recent call last):
File "get-pip.py", line 27077, in <module>
main()
File "get-pip.py", line 135, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 111, in bootstrap
monkeypatch_for_cert(tmpdir)
File "get-pip.py", line 92, in monkeypatch_for_cert
from pip._internal.commands.install import InstallCommand
File "/tmp/tmp99gxi6nh/pip.zip/pip/_internal/commands/__init__.py", line 9, in <module>
File "/tmp/tmp99gxi6nh/pip.zip/pip/_internal/cli/base_command.py", line 13, in <module>
File "/tmp/tmp99gxi6nh/pip.zip/pip/_internal/cli/cmdoptions.py", line 23, in <module>
File "/tmp/tmp99gxi6nh/pip.zip/pip/_internal/cli/parser.py", line 12, in <module>
File "/tmp/tmp99gxi6nh/pip.zip/pip/_internal/configuration.py", line 26, in <module>
File "/tmp/tmp99gxi6nh/pip.zip/pip/_internal/utils/logging.py", line 13, in <module>
File "/tmp/tmp99gxi6nh/pip.zip/pip/_internal/utils/misc.py", line 40, in <module>
File "/tmp/tmp99gxi6nh/pip.zip/pip/_internal/locations/__init__.py", line 14, in <module>
File "/tmp/tmp99gxi6nh/pip.zip/pip/_internal/locations/_distutils.py", line 9, in <module>
ModuleNotFoundError: No module named 'distutils.cmd'
解决:
$ apt-get install python3-distutils
重新安装pip:
$ python3 get-pip.py
测试安装成功否:
$ pip3 --version
如果linux中已经安装cuda cudnn等,可以用如下方式安装pytorch1.8.2:
pip3 install torch==1.8.2+cu111 torchvision==0.9.2+cu111 torchaudio==0.8.2 -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html
如果在windows中已经成功安装 cuda cudnn (例如toolkits-11.2):
使用如下命令在windows中安装pytorch:
pip3 install torch==1.8.2+cu111 torchvision==0.9.2+cu111 torchaudio===0.8.2 -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html