centos7 python升级python3.7
程序员文章站
2022-03-01 17:24:38
...
centos7 升级python3.7
更新&&安装支撑
更新源&&包
#centos 7 添加阿里云镜像
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum install epel-release
#更新包
yum -y update
安装相关支撑
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel libffi-devel
yum -y install gcc gcc-c++ kernel-devel
安装
下载解压
cd /usr/local
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
tar -xzvf Python-3.7.0.tgz
创建python3.7文件夹
配置安装路径&&编译
mkdir python3.7
cd Python-3.7.0
./configure --prefix=/usr/local/python3.7
make && make install
更换系统默认的python和pip版本
备份系统旧的python版本
以备接下来yum依赖
mv /usr/bin/python /usr/bin/python2.7
mv /usr/bin/pip /usr/bin/pipold
建立指向新python3和pip3的软链接
ln -s /usr/local/python3/bin/python3.5 /usr/bin/python
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip
检查python和pip版本
python --version
pip --version
更新yum相关设置
因yum依赖python2,故修改文件
vim /usr/bin/yum
把第一行改了
#!/usr/bin/python
—改成—> #!/usr/bin/python2.7
emmmm
用yum时可能又会出现另一种报错
Is this ok [y/d/N]: y
Downloading packages:
File "/usr/libexec/urlgrabber-ext-down", line 28
except OSError, e:
^
SyntaxError: invalid syntax
解决方法
vim /usr/libexec/urlgrabber-ext-down
将第一行#!/usr/bin/python
改为 #!/usr/bin/python2.7
即可
EeeeeeeeeeerroR
升级新版pip 之后,有可能是与旧版冲突出现的下面的错误
[[email protected] bin]# pip -V
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip._internal.cli'
解决方法
# 下载安装脚本
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
# 运行安装脚本
sudo python get-pip.py
然后好了
[[email protected] bin]# pip --version
pip 20.0.2 from /usr/local/python3/lib/python3.7/site-packages/pip (python 3.7)
上一篇: LaravelS通过Swoole加速Laravel/Lumen步骤详解
下一篇: Centos使用make menuconfig出现 *** Unable to find the ncurses libraries or the
推荐阅读
-
Mac OS X10.9安装的Python2.7升级Python3.3步骤详解
-
python远程邮件控制电脑升级版
-
Ubuntu18.04一次性升级Python所有库的方法步骤
-
详解windows python3.7安装numpy问题的解决方法
-
腾讯云下的CentOS7 安装最新版Python3.7.0
-
python升级带来的yum异常(解决错误File "/usr/bin/yum", line 30 except KeyboardInterrupt, e:)
-
Python3.7 新特性之dataclass装饰器
-
python3快速安装升级pip3
-
Python第五十一天 python2升级为python3
-
MacOS配置Anaconda3(Miniconda3)下Python3.6、Python3.7和Python2.7环境和基础机器学习、神经网络相关包详解(版本号对应)