centos下pip install的ssl问题

centos下pip install的ssl问题

困扰了我两天时间,几乎没干啥了

原因
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.
  
  • 确认安装python的时候 依赖包正确安装

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
  • 下载python和安装 配置

>>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
  

pip安装

直接安装报错

pip3 install 包名字


错误信息
pip install fails with “connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)

参考Stack overflow网站上面的解决方案:

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

你可能感兴趣的:(python错误笔记)