困扰了我两天时间,几乎没干啥了
原因
Note: Sometime during April 2018, the Python Package Index was migrated from pypi.python.org to pypi.org. This means "trusted-host" commands using the old domain no longer work.
yum install gcc -y
yum -y groupinstall "Development tools"
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
>>wget -c https://www.python.org/ftp/python/3.6.6/Python-3.7.1.tgz
解压
>>tar -xvzf Python-3.6.6.tgz
进入目录
>>cd Python-3.6.6/
添加配置
>>./configure --prefix=/usr/local/python36 --with-ssl --enable-shared --enable-optimizations
编译和安装
>>make&&make install
>>vi /etc/profile
添加以下两句
export PYTHON_HOME=/usr/local/python36
export PATH=$PATH:$PYTHON_HOME/bin
立即生效命令
>>source /etc/profile
直接安装报错
pip3 install 包名字
错误信息
pip install fails with “connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)”
https://stackoverflow.com/questions/25981703/pip-install-fails-with-connection-error-ssl-certificate-verify-failed-certi
>>pip3 install --index-url=http://pypi.python.org/simple/ --trusted-host pypi.python.org flask
>>pip3 install --trusted-host pypi.org --trusted-host files.pythonhosted.org pip setuptools
如果还是不可以,需要配置pip.conf文件信息
>>cd ~
>>ls .config/pip/pip.conf 查看配置文件是否存在
不存在则新建
>>mkdir -p .config/pip
>>vi .config/pip/pip.conf
添加:
[global]
trusted-host = pypi.python.org
pypi.org
files.pythonhosted.org
pip3 install flask