Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

解决腾讯云安装最新的 python 包报错问题 #565

Closed
yoa1226 opened this issue Apr 22, 2023 · 2 comments
Closed

解决腾讯云安装最新的 python 包报错问题 #565

yoa1226 opened this issue Apr 22, 2023 · 2 comments
Labels
documentation Improvements or additions to documentation

Comments

@yoa1226
Copy link

yoa1226 commented Apr 22, 2023

解决腾讯云安装最新的 python 包报错问题

问题引入

而我在本地却能够正常, 安装相关 Python 云服务报下面的错误。

No matching distribution found for gradio==3.23

在查阅相关资料后仍没有解决。于是猜想是不是 Python 版本的问题。本地电脑 Python 版本是:

~ python3 -V
Python 3.9.6

云服务器 Python 版本是:

~ python3 -V
Python 3.6.8

重要环境说明

  • 云服务厂商: 腾讯云
  • OS: CentOS7.6
  • 云服务 Python 版本: 3.6.8

重装 Python

安装 Python 主要是参考一下文章:

腾讯云服务器如何安装Python的运行环境? - 酒坛坛儿的回答 - 知乎

centos 安装python3.8报错

下载解压

# 下载安装包
wget https://www.python.org/ftp/python/3.9.9/Python-3.9.9.tgz

# 解压缩
tar -zxf Python-3.9.9.tgz

OS 环境准备

执行下面的更新操作系统的包

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

特别注意必须安装下面的包

yum install libffi-devel

不然会在 Python 安装其他包的时候报下面的错误

ModuleNotFoundError: No module named '_ctypes'

设置 Python 安装路径

cd  Python-3.9.9

./configure --prefix=/usr/local/python39

注意 不能 添加 --enable-optimizations 参数, 不然会报下面的错误。

returned NULL without setting an error generate-posix-vars failed

安装 Python

# 这一步需要几分钟的时间
make clean & make && make install

安装后配置

# 创建启动软连接
ln -s /usr/local/python39/bin/python3.9 /usr/bin/python39

# 安装pip
python39 -m pip install -U pip

# 创建python3.x对应的pip软连接
ln -s /usr/local/python39/bin/pip /usr/bin/pip39

查看版本

~ python39 -V
Python 3.9.9

安装 python 包

python39 -m pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple
@binary-husky binary-husky added the documentation Improvements or additions to documentation label Apr 22, 2023
@wangguijiepedeval
Copy link

请问一下,找不到模块“_bz2”,但是已经下载了bzip2-devel是怎么回事呢?:(
详细报错: File "/usr/local/python39/lib/python3.9/bz2.py", line 18, in
from _bz2 import BZ2Compressor, BZ2Decompressor
ModuleNotFoundError: No module named '_bz2'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants