Linux 下python3 pip ssl报错

  1. 由于 python 新版本后,pip安装包时会出现,ssl报错的问题

  2. 下载 安装 openssl

    	apt-get openssl
    	apt-get libssl-dev
    
  3. centos 版本

    	yum install openssl
    	yum install openssl-devel -y
    
  4. 安装好后,进入安装包 /python3

  5. 找到 Modules/Setup ,vi 打开
    vi /usr/local/src/python3/Modules/Setup

  6. 修改以下代码

    	# Socket module helper for socket(2)
    	_socket socketmodule.c 
    	# Socket module helper for SSL support; you must comment out the other
    	# socket line above, and possibly edit the SSL variable:
    	#SSL=/usr/local/ssl
    	_ssl _ssl.c \
    	-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
    	-L$(SSL)/lib -lssl -lcrypto
    
  7. 接着重新安装python

    	sudo .\configure --with-ssl
    	sudo make && make install
    
  8. 随后查看操作是否成功

    	pip3 install requests
    

操作成功!!!

摘录来源 https://blog.csdn.net/xuanlv2017/article/details/78524562

你可能感兴趣的:(基础使用,python,linux)