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

centos7 升级到python3 #11

Open
dalaolala opened this issue Jan 3, 2020 · 3 comments
Open

centos7 升级到python3 #11

dalaolala opened this issue Jan 3, 2020 · 3 comments

Comments

@dalaolala
Copy link
Owner

dalaolala commented Jan 3, 2020

目前python2已经完全不更新了
而且会莫名其妙出现各种各样的问题

下面是升级到python3的方法

1、手动安装

curl -O https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz

tar xf Python-3.5.0.tgz
cd Python-3.5.0
./configure
make
sudo make install

提示没有gcc,则要先安装一下

yum install gcc gcc-c++ -y

如果提示出现 'Ignoring ensurepip failure: pip 7.1.2 requires SSL/TLS'

yum install openssl-devel

2、使用一键脚本安装

bash <(curl -sL https://python3.netlify.com/install.sh)

参考这里:https://github.com/Jrohy/python3-install

@dalaolala
Copy link
Owner Author

dalaolala commented Jan 26, 2022

安装pyhton3.7

1、下载安装包

https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz

3、配置安装环境

 #否则将会提示No module named‘_ctypes’
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 -y libffi-devel zlib1g-dev
yum install zlib* -y
yum -y install gcc
yum -y groupinstall "Development tools"

4、编译安装python

tar xvf Python-3.7.0.tar 
cd Python-3.7.0
./configure --prefix=/usr/local/python3.7/ --enable-optimizations
make && make install

5、设置默认python

ln -s /usr/local/python3.7/bin/python3.7 /usr/bin/python3

ln -s /usr/local/python3.7/bin/pip3.7 /usr/bin/pip3

安装pyhton3.8

wget https://www.python.org/ftp/python/3.8.1/Python-3.8.1.tgz

配置安装环境

 #否则将会提示No module named‘_ctypes’
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 -y libffi-devel zlib1g-dev
yum install zlib* -y
yum -y install gcc
yum -y groupinstall "Development tools"

解压安装

# 解压压缩包
tar -zxvf Python-3.8.1.tgz  

# 进入文件夹
cd Python-3.8.1

# 配置安装位置
./configure prefix=/usr/local/python3

# 安装
make && make install

添加软链接

#添加python3的软链接 
ln -s /usr/local/python3/bin/python3.8 /usr/bin/python3 

#添加 pip3 的软链接 
ln -s /usr/local/python3/bin/pip3.8 /usr/bin/pip3

@dalaolala
Copy link
Owner Author

编译很慢解决办法

./configure --prefix=/usr/local/python3.7/

@dalaolala
Copy link
Owner Author

快速的安装python3.8版本

Centos 7 自带Python2.7.5版本。而默认的 YUM 安装的python3是 3.6版本,遂升级到3.8版本

# 仓库注册
yum install -y centos-release-scl 
# 安装python3.8
yum install -y rh-python38 which 

创建软链接

ln -s /opt/rh/rh-python38/root/usr/bin/python3 /usr/bin/python3
ln -s /opt/rh/rh-python38/root/usr/bin/pip3 /usr/bin/pip3

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

No branches or pull requests

1 participant