我已经在我的本地机器上成功安装了Python 3.4和Python 3.6,但无法安装带有pip3的包。

当我执行pip3 install <package>时,我得到以下SSL相关错误:

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting <package>
  Could not fetch URL https://pypi.python.org/simple/<package>/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping
  Could not find a version that satisfies the requirement <package> (from versions: )
No matching distribution found for <package>

如何修复我的Python3。pip install <package>?


当前回答

在我使用Mac的情况下,我删除了 /应用程序/ Python 3.7。 因为我已经通过brew安装了Python3.7。

但这是信息的一个触发点

pip配置了需要TLS/SSL的位置,但是Python中的SSL模块不可用。

我在这种情况下做了什么

我再次下载了macOS 64位安装程序,并安装。 双击/Applications/Python3.6/Install Certificates.command和/Applications/Python3.6/Update Shell Profile.command。 重启mac 我不确定,但可能有助于成功的是pip.conf。参见pip安装失败。

其他回答

特穆克斯

这是因为我没有安装现有的openssl版本。

pkg install openssl-tool

如果在窗户和使用蟒蛇,比我先解决它,

conda activate
pip install <lib>

这对我很管用。

python文档实际上非常清楚,按照说明做了工作,而我在这里找到的其他答案并没有解决这个问题。

首先,安装python 3.x。例如3.6.2版本https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz 通过运行brew install openssl,确保已经安装了openssl tar xvzf python -3.6.2.tar。xz && cd Python-3.6.2 然后如果python版本< 3.7,则运行

CPPFLAGS="-I$(brew -prefix openssl)/include" \ LDFLAGS="-L$(brew -prefix openssl)/lib" \ . / configure——with-pydebug 5. 最后,运行make -s -j2 (-s是沉默标志,-j2告诉您的机器使用2个作业)

这个问题可能是库丢失造成的。

在安装python 3.6之前,请确保安装了python所需的所有库。

$ sudo apt-get install build-essential checkinstall 
$ sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

更多信息请参见如何在Ubuntu和LinuxMint上安装Python 3.6.0

我可以通过更新这个文件中的python版本来修复这个问题。 pyenv: version ' 3.6.5'未安装(由/Users/taruntarun/.python-version设置) 虽然我安装了最新版本,但我的命令仍然使用旧版本3.6.5

转到3.7.3版本