【Python】CentOS7安装Python3.7以及注意事项
linux安装python3时需要依赖一些编译环境,不注意的话,往往一件简单的事情搞得非常麻烦。下面简单记录下:
安装依赖
yum install gcc-c++
yum install pcre pcre-devel
yum install zlib zlib-devel
yum install openssl openssl--devel
开始安装
- 下载:
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz - 解压:
tar -zxvf Python-3.7.0.tgz - 建立一个空文件夹,用于存放python3程序:
mkdir /usr/local/python3 - 执行配置文件,编译,编译安装:
cd Python-3.7.0
./configure --prefix=/usr/local/python3
make && make install - 建立软连接:
ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3
补充
如果/usr/local/python3/bin/没有pip、pip3.7,则需要:
- 下载pip:wget https://bootstrap.pypa.io/get-pip.py
- 安装:python3 get-pip.py
- 升级:pip3 install --upgrade pip