Python3 3.6版 安装pip 出现错误 ModuleNotFoundError: No module named ‘distutils.util‘

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

 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值