有趣生活

当前位置:首页>科技>python 安装包版本问题如何解决python安装依赖库过程中报ssl错误的问题

python 安装包版本问题如何解决python安装依赖库过程中报ssl错误的问题

发布时间:2026-07-21阅读(1)

导读一、报错问题复现[root@db-master~]#whichpip3/usr/bin/pip3[root@db-master~]#pip3installr....一、报错问题复现

[root@db-master ~]# which pip3/usr/bin/pip3[root@db-master ~]# pip3 install requestWARNING: pip is configured with locations that require TLS/ssl, however the ssl module in Python is not available.WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by SSLError("Cant connect to HTTPS URL because the SSL module is not available."): /simple/request/WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by SSLError("Cant connect to HTTPS URL because the SSL module is not available."): /simple/request/WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by SSLError("Cant connect to HTTPS URL because the SSL module is not available."): /simple/request/WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by SSLError("Cant connect to HTTPS URL because the SSL module is not available."): /simple/request/WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by SSLError("Cant connect to HTTPS URL because the SSL module is not available."): /simple/request/Could not fetch URL https://pypi.org/simple/request/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host=pypi.org, port=443): Max retries exceeded with url: /simple/request/ (Caused by SSLError("Cant connect to HTTPS URL because the SSL module is not available.")) - skippingERROR: Could not find a version that satisfies the requirement request (from versions: none)ERROR: No matching distribution found for requestWARNING: 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("Cant connect to HTTPS URL because the SSL module is not available.")) - skipping

二、家目录下创建pip配置文件

[root@db-master ~]# mkdir .pip

[root@db-master ~]# cd .pip/

[root@db-master ~/.pip]# vim pip.conf

使用豆瓣的源

[root@db-master ~/.pip]# cat pip.conf

[global]

timeout = 600

index-url = http://pypi.douban.com/simple/

[install]

use-mirrors = true

mirrors = http://pypi.douban.com/simple/

trusted-host = pypi.douban.com

小试牛刀,发现很爽

[root@db-master ~/.pip]# pip3 install request

WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.

Collecting request

Downloading http://pypi.doubanio.com/packages/67/fc/30193d66338a12cc1389e799a4fa27d29763cb075ced80fa2be9b2571224/request-1.0.117.tar.gz

Requirement already satisfied: requests in /usr/lib/python3.6/site-packages (from request)

Requirement already satisfied: urllib3>=1.21.1 in /usr/lib/python3.6/site-packages (from requests->request)

Installing collected packages: request

Running setup.py install for request ... done

Successfully installed request-1.0.117

三、更新pip

[root@db-master ~/.pip]# pip3 install --upgrade --trusted-host pypi.org --trusted-host files.pythonhosted.org pip

WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.Collecting pipDownloading http://pypi.doubanio.com/packages/a4/6d/6463d49a933f547439d6b5b98b46af8742cc03ae83543e4d7688c2420f8b/pip-21.3.1-py3-none-any.whl (1.7MB)28% |█████████▏ | 491kB 995kB/s eta 0:00:029% |█████████▎ | 501kB 994kB/s eta 0:00:029% |█████████▌ | 512kB 1.5MB/s eta 0:00:030% |█████████▊ | 522kB 2.5MB/s eta 0:00:030% |█████████▉ | 532kB 2.2MB/s eta 0:00:031% |██████████ | 542kB 2.2MB/s eta 0:00:032% |██████████▎ | 552kB 2.6MB/s eta 0:00:32% |██████████▌ | 563kB 2.7MB/s eta 0:00:33% |██████████▋ | 573kB 3.7MB/s eta 0:00:33% |██████████▉ | 583kB 3.7MB/s eta 0:00:34% |███████████ | 593kB 2.6MB/s eta 0:00:35% |███████████▏ | 604kB 1.9MB/s eta 0:0035% |███████████▍ | 614kB 1.9MB/s eta 0:0036% |███████████▋ | 624kB 1.9MB/s eta 0:0036% |███████████▉ | 634kB 2.4MB/s eta 0:0037% |████████████ | 645kB 2.4MB/s eta 0:0038% |████████████▏ | 655kB 2.4MB/s eta 0:038% |████████████▍ | 665kB 2.4MB/s eta 0:039% |████████████▌ | 675kB 1.5MB/s eta 0:039% |████████████▊ | 686kB 1.4MB/s eta 0:040% |█████████████ | 696kB 1.7MB/s eta 0:040% |█████████████▏ | 706kB 2.2MB/s eta 0:41% |█████████████▎ | 716kB 1.3MB/s eta 0:42% |█████████████▌ | 727kB 1.3MB/s eta 0:42% |█████████████▊ | 737kB 1.3MB/s eta 0:43% |█████████████▉ | 747kB 1.2MB/s eta 0:43% |██████████████ | 757kB 1.2MB/s eta 0:44% |██████████████▎ | 768kB 1.2MB/s eta 045% |██████████████▌ | 778kB 1.8MB/s eta 045% |██████████████▋ | 788kB 1.6MB/s eta 046% |██████████████▉ | 798kB 1.5MB/s eta 046% |███████████████ | 808kB 1.5MB/s eta 047% |███████████████▏ | 819kB 3.1MB/s eta48% |███████████████▍ | 829kB 3.0MB/s eta48% |███████████████▋ | 839kB 2.7MB/s eta49% |███████████████▉ | 849kB 3.3MB/s eta49% |████████████████ | 860kB 3.6MB/s eta50% |████████████████▏ | 870kB 3.6MB/s eta51% |████████████████▍ | 880kB 3.6MB/s eta51% |████████████████▌ | 890kB 4.0MB/s eta52% |████████████████▊ | 901kB 4.3MB/s eta52% |█████████████████ | 911kB 4.3MB/s eta53% |█████████████████ | 921kB 4.3MB/s eta54% |█████████████████▎ | 931kB 3.9MB/s et54% |█████████████████▌ | 942kB 4.3MB/s et55% |█████████████████▊ | 952kB 2.7MB/s et55% |█████████████████▉ | 962kB 2.2MB/s et56% |██████████████████ | 972kB 2.1MB/s et57% |██████████████████▎ | 983kB 2.1MB/s e57% |██████████████████▍ | 993kB 2.4MB/s e58% |██████████████████▋ | 1.0MB 2.4MB/s e58% |██████████████████▉ | 1.0MB 1.3MB/s e59% |███████████████████ | 1.0MB 1.3MB/s e60% |███████████████████▏ | 1.0MB 1.4MB/s60% |███████████████████▍ | 1.0MB 1.4MB/s61% |███████████████████▋ | 1.1MB 1.8MB/s61% |███████████████████▊ | 1.1MB 2.2MB/s62% |████████████████████ | 1.1MB 1.6MB/s62% |████████████████████▏ | 1.1MB 1.5MB/s63% |████████████████████▍ | 1.1MB 1.5MB/s64% |████████████████████▌ | 1.1MB 1.5MB/s64% |████████████████████▊ | 1.1MB 3.1MB/s65% |█████████████████████ | 1.1MB 3.1MB/s65% |█████████████████████ | 1.1MB 2.2MB/s66% |█████████████████████▎ | 1.1MB 2.2MB/67% |█████████████████████▌ | 1.2MB 2.2MB/67% |█████████████████████▊ | 1.2MB 2.1MB/68% |█████████████████████▉ | 1.2MB 3.3MB/68% |██████████████████████ | 1.2MB 1.9MB/69% |██████████████████████▎ | 1.2MB 1.8MB70% |██████████████████████▍ | 1.2MB 1.8MB70% |██████████████████████▋ | 1.2MB 1.8MB71% |██████████████████████▉ | 1.2MB 1.8MB71% |███████████████████████ | 1.2MB 2.2MB72% |███████████████████████▏ | 1.2MB 1.9M73% |███████████████████████▍ | 1.3MB 1.8M73% |███████████████████████▋ | 1.3MB 1.9M74% |███████████████████████▊ | 1.3MB 1.9M74% |████████████████████████ | 1.3MB 3.1M75% |████████████████████████▏ | 1.3MB 3.376% |████████████████████████▍ | 1.3MB 2.676% |████████████████████████▌ | 1.3MB 2.777% |████████████████████████▊ | 1.3MB 2.877% |█████████████████████████ | 1.3MB 2.978% |█████████████████████████ | 1.4MB 3.479% |█████████████████████████▎ | 1.4MB 3.79% |█████████████████████████▌ | 1.4MB 2.80% |█████████████████████████▋ | 1.4MB 2.80% |█████████████████████████▉ | 1.4MB 2.81% |██████████████████████████ | 1.4MB 2.81% |██████████████████████████▎ | 1.4MB 282% |██████████████████████████▍ | 1.4MB 283% |██████████████████████████▋ | 1.4MB 183% |██████████████████████████▉ | 1.4MB 184% |███████████████████████████ | 1.5MB 284% |███████████████████████████▏ | 1.5MB85% |███████████████████████████▍ | 1.5MB86% |███████████████████████████▋ | 1.5MB86% |███████████████████████████▊ | 1.5MB87% |████████████████████████████ | 1.5MB87% |████████████████████████████▏ | 1.5MB88% |████████████████████████████▎ | 1.5MB89% |████████████████████████████▌ | 1.5MB89% |████████████████████████████▊ | 1.5MB90% |█████████████████████████████ | 1.6MB90% |█████████████████████████████ | 1.6MB91% |█████████████████████████████▎ | 1.6M92% |█████████████████████████████▌ | 1.6M92% |█████████████████████████████▋ | 1.6M93% |█████████████████████████████▉ | 1.6M93% |██████████████████████████████ | 1.6M94% |██████████████████████████████▎ | 1.695% |██████████████████████████████▍ | 1.695% |██████████████████████████████▋ | 1.696% |██████████████████████████████▉ | 1.796% |███████████████████████████████ | 1.797% |███████████████████████████████▏| 1.98% |███████████████████████████████▍| 1.98% |███████████████████████████████▋| 1.99% |███████████████████████████████▊| 1.99% |████████████████████████████████| 1.100% |████████████████████████████████| 1.7MB 3.9MB/sInstalling collected packages: pipSuccessfully installed pip-21.3.1You are using pip version 21.3.1, however version 22.1.2 is available.You should consider upgrading via the pip install --upgrade pip command.

[root@db-master ~/.pip]# pip -V

pip 21.3.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)

[root@db-master ~/.pip]# pip3 -V

WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.

Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.

To avoid this problem you can invoke Python with -m pip instead of running pip directly.

pip 21.3.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)

[root@db-master ~/.pip]#

OK,大家如果遇到的话可以按此方法解决。

迁移python依赖库

首先要确保新旧服务器的python环境一致,操作如下:

1、导出依赖库

[root@db-master ~/.pip]# pip freeze > /tmp/requirements.txt

[root@db-master ~/.pip]# cat /tmp/requirements.txt

cached-property==1.5.1

。。。

2、在新服务器上安装

[root@db-master ~/.pip]# scp /tmp/requirements.txt db-slave:~

[root@db-slave ~]# pip3 install -r requirements.txt

Looking in indexes: http://pypi.douban.com/simple/

Collecting cached-property==1.5.1

Downloading http://pypi.doubanio.com/packages/3b/86/85c1be2e8db9e13ef9a350aecd6dea292bd612fa288c2f40d035bb750ded/cached_property-1.5.1-py2.py3-none-any.whl (6.0 kB)

Collecting chardet==3.0.4

。。。

TAGS标签:  python  安装  包版本  版本  问题  python 安装包

Copyright © 2024 有趣生活 All Rights Reserve吉ICP备19000289号-5 TXT地图HTML地图XML地图