首页 > Python资料 博客日记
ERROR: Package ‘networkx‘ requires a different Python: 3.8.10 not in ‘>=3.9‘
2024-06-22 15:00:06Python资料围观77次
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 <enter> 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_pointif __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
标签:
相关文章
最新发布
- 【Python系列】SQLAlchemy 基本介绍
- 【Python】selenium 的EC.presence_of_element_located 和 EC.element_to_be_clickable 的区别
- 从零到一!超详细Pycharm安装教程(图解+详细步骤)
- python json jsonl 的用法
- 【Python篇】深度探索NumPy(下篇):从科学计算到机器学习的高效实战技巧
- boto3:Python连接S3对象存储并进行文件操作(上传、下载、删除)
- 全网最适合入门的面向对象编程教程:50 Python函数方法与接口-接口和抽象基类
- Python pycryptodome类库使用学习总结
- import torch 报错:WinError 126
- 如何在Java中实现邮件发送功能?
点击排行
- 版本匹配指南:Numpy版本和Python版本的对应关系
- Python 可视化 web 神器:streamlit、Gradio、dash、nicegui;低代码 Python Web 框架:PyWebIO
- 版本匹配指南:PyTorch版本、torchvision 版本和Python版本的对应关系
- 相关性分析——Pearson相关系数+热力图(附data和Python完整代码)
- Could not build wheels for llama-cpp-python, which is required to install pyproject.toml-based proj
- Python pyinstaller打包exe最完整教程
- Anaconda版本和Python版本对应关系(持续更新...)
- Python与PyTorch的版本对应