Linux 安装Python 3 (centos,ubuntu,deepin)
yum install wget -y
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc* make -y
#会提示没有_ctype 模块
yum install libffi-devel -y
wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz
1.之前什么都没有做 直接下载Python3.7的包 tar -xzvf Python-3.7.2.tgz cd Python-3.7.2 ./configure --prefix=/usr/local/python3 make && make install 创建软连接 ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3 ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3 添加环境变量 vim /etc/profile PATH="/usr/local/python3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin" source /etc/profile
安装上面一顿操作之后 各种问题
1.在普通用户下执行pytho3和pip3 没有问题但是在root用户下提示命令找不到 2.pip3 install 包的时候报错 pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
解决:
1.切换到root用户下进行安装 2.openssl版本过低或者不存在 so yum install openssl-devel -y 3.cd Python-3.7.2 ./configure --prefix=/usr/local/python3 --with-ssl make && make install 创建软连接 ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3 ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3 添加环境变量 echo $PATH 如果存在 则不需执行以下命令 vim /etc/profile 在最后一行添加: PATH="/usr/local/python3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin" source /etc/profile
通过以上安装之后如果pip 下载的时候 还出现SSL相关的错误 在root 权限下执行 pip3 install XXXX -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com
通过以上测试在centos7 安装的python3.7 使用很舒服...