出现错误:
ERROR: Could not find a version that satisfies the requirement ipython (from versions: none)
ERROR: No matching distribution found for ipython
WARNING: You are using pip version 21.2.3; however, version 21.2.4 is available.
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/ipython/
Could not fetch URL https://pypi.douban.com/simple/ipython/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.douban.com', port=443): Max retries exceeded with url: /simple/ipython/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
ERROR: Could not find a version that satisfies the requirement ipython (from versions: none)
ERROR: No matching distribution found for ipython
WARNING: You are using pip version 21.2.3; however, version 21.2.4 is available.
You should consider upgrading via the '/usr/local/python3.9/bin/python3.9 -m pip install --upgrade pip' command.
提示升级版本到21.2.4 ,修改配置文件。
[root@localhost .pip]# vim pip.conf
#配置pip.conf文件
1 [global]
2 index-url=https://mirrors.aliyun.com/pypi/simple
3 extra-index-url=
4 https://pypi.tuna.tsinghua.edu.cn/simple/
5 https://pypi.mirrors.ustc.edu.cn/simple/
6 https://pypi.douban.com/simple/
7 [install]
8 trusted-host=mirrors.aliyun.com
#这里使用了https://www.cnblogs.com/night-xing/p/12094099.html的配置,主要解决:While reading from '/Users/***/.pip/pip.conf' [line 4]: option 'extra-index-url' in section 'global' already exists的问题。
出现错误
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
进入Python3.9 提示无法找到SSL模块。
[root@localhost tar]# python3.9
Python 3.9.7 (default, Sep 9 2021, 21:07:26)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-23)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/python3.9/lib/python3.9/ssl.py", line 98, in <module>
import _ssl # if we can't import it, let the error propagate
ModuleNotFoundError: No module named '_ssl'
修改python源码包解压后的那个目录下的Modules/Setup,又又报错误:
Setup文件需要修改的地方
# Socket module helper for socket(2)
_socket socketmodule.c timemodule.c
#去掉这个5个地方的注释
# 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
执行编译安装后提示错误:
./Modules/_ssl.c: 在函数‘set_verify_flags’中:
./Modules/_ssl.c:3614: 警告:赋值时将整数赋给指针,未作类型转换
./Modules/_ssl.c: 在函数‘set_host_flags’中:
./Modules/_ssl.c:3810: 警告:赋值时将整数赋给指针,未作类型转换
./Modules/_ssl.c: 在函数‘_add_ca_certs’中:
./Modules/_ssl.c:4112: 警告:传递‘BIO_new_mem_buf’的第 1 个实参时丢弃了指针目标类型的限定
/usr/include/openssl/bio.h:668: 附注:需要类型‘void *’,但实参的类型为‘const void *’
make: *** [Modules/_ssl.o] 错误 1
找到原因,o(╥﹏╥)o
[root@localhost Python-3.9.7]# openssl version
OpenSSL 1.0.1e-fips 11 Feb 2013
# 原来是这个版本太老了,去球升级版本吧。
下载openssl version 最新版本升级,具体步骤参考以下博主的:python3 安装ssl编译问题_luckydoit的博客-CSDN博客
[root@localhost .pip]# openssl version
OpenSSL 3.0.0 7 sep 2021 (Library: OpenSSL 3.0.0 7 sep 2021)
更新成功后同时修改SSL=/usr/local/ssl路径后,发现还是报错:
ERROR: Could not find a version that satisfies the requirement ipython3 (from versions: none)
ERROR: No matching distribution found for ipython3
WARNING: You are using pip version 21.2.3; however, version 21.2.4 is available.
You should consider upgrading via the '/usr/local/bin/python3.9 -m pip install --upgrade pip' command.
不在提示ssl证书错误,最后尝试使用命令“pip install 包名-i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com” 终于安装成功 ipython