ERROR: Package ‘networkx‘ requires a different Python: 3.8.10 not in ‘>=3.9‘
创始人
2025-01-09 14:36:58
0

thomas@ubuntu:~$ pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu

结果报错:

ERROR: Package 'networkx' requires a different Python: 3.8.10 not in '>=3.9'

查询python的版本

thomas@ubuntu:~$ python3 --version
Python 3.8.10

需要安装最新版的python

参考链接:
https://blog.csdn.net/DEVELOPERAA/article/details/133743389

$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt update
$ sudo apt install python3.11

设置默认版本

如果您在 Ubuntu 系统中安装了多个版本的 Python,并且只想将一个版本设置为默认版本,那么您需要执行一些额外的步骤,如下

$ python3 --version Python 3.8.10 $ ls /usr/bin/python3.* /usr/bin/python3.11  /usr/bin/python3.8  /usr/bin/python3.8-config  /usr/bin/python3.8-coverage $ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1 update-alternatives: using /usr/bin/python3.8 to provide /usr/bin/python3 (python3) in auto mode $ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 2 update-alternatives: using /usr/bin/python3.11 to provide /usr/bin/python3 (python3) in auto mode $ sudo update-alternatives --config python3 There are 2 choices for the alternative python3 (providing /usr/bin/python3).    Selection    Path                 Priority   Status ------------------------------------------------------------ * 0            /usr/bin/python3.11   2         auto mode   1            /usr/bin/python3.11   2         manual mode   2            /usr/bin/python3.8    1         manual mode  Press  to keep the current choice[*], or type selection number: 0 $ python3 --version    Python 3.11.8  

再次执行

pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu

报错

ModuleNotFoundError: No module named 'distutils.util'
 

由于刚刚安装了python3.11,所以需要安装python3.11-distutils

sudo apt-get install python3.11-distutils

再次执行

pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu
 

报错:

ImportError: cannot import name 'html5lib' from 'pip._vendor' (/usr/lib/python3/dist-packages/pip/_vendor/__init__.py)
 

这里可以参考

https://zhuanlan.zhihu.com/p/664770225

thomas@ubuntu:~$ pip show pip
Name: pip
Version: 20.0.2

curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11

修改/usr/bin/pip3,版本修改为24.0

sudo vi /usr/bin/pip3

#!/usr/bin/python3
# EASY-INSTALL-ENTRY-SCRIPT: 'pip==24.0','console_scripts','pip3'
__requires__ = 'pip==24.0'
import re
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(
        load_entry_point('pip==24.0', 'console_scripts', 'pip3')()
    )
 

再次执行就OK了

pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu

相关内容

热门资讯

透视线上!poker worl... 透视线上!poker world辅助器,wepoker底牌透视,秘籍教程(其实有挂)-哔哩哔哩1、透...
此事备受玩家关注!微乐陕西三代... 此事备受玩家关注!微乐陕西三代自建房挂,天天互娱辅助器免费下载,切实教程(果然有挂)-哔哩哔哩1、玩...
透视工具!wpk辅助最怕三个东... 透视工具!wpk辅助最怕三个东西(透视)开挂辅助攻略(原来是真的挂)-哔哩哔哩1、任何wpk辅助最怕...
透视玄学!wepoker有辅助... 透视玄学!wepoker有辅助工具吗,we-poker有人玩吗,练习教程(本来是有挂)-哔哩哔哩we...
截至目前!微乐小程序微乐房间怎... 截至目前!微乐小程序微乐房间怎么开挂,决战十水三辅助,可靠教程(都是是有挂)-哔哩哔哩1、微乐小程序...
透视安卓!hhpoker德州透... 透视安卓!hhpoker德州透视挂(透视)开挂辅助软件(其实是真的挂)-哔哩哔哩1、hhpoker德...
透视计算!hhpoker万能辅... 透视计算!hhpoker万能辅助器,hhpoker的辅助是真的吗,诀窍教程(果然存在有挂)-哔哩哔哩...
现有关情况通报如下!哈灵脚本辅... 现有关情况通报如下!哈灵脚本辅助,潮汕木虱有辅助挂吗,辅助教程(一直真的是有挂)-哔哩哔哩1、让任何...
透视辅助器!pokerrrr2... 透视辅助器!pokerrrr2辅助(透视)开挂辅助挂(确实是真的挂)-哔哩哔哩一、pokerrrr2...
今日!玖游卡五星辅助,微信微乐... 今日!玖游卡五星辅助,微信微乐辅助免费,可靠教程(确实是有挂)-哔哩哔哩1、操作简单,无需注册,只需...