问题:使用pip3安装软件包时,“ Python中的ssl模块不可用”

我已经在本地计算机上成功安装了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.x安装,以便可以使用安装软件包pip install <package>

I’ve install Python 3.4 and Python 3.6 on my local machine successfully, but am unable to install packages with pip3.

When I execute pip3 install <package>, I get the following SSL related error:

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>

How can I fix my Python3.x install so that I can install packages with pip install <package>?


回答 0

在Ubuntu中安装Python 3.6和pip3的分步指南

  1. 为Python和ssl安装必要的软件包: $ sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

  2. https://www.python.org/ftp/python/下载“ Python-3.6.8.tar.xz”并将其解压缩到您的主目录中。

  3. 在该目录中打开终端并运行: $ ./configure

  4. 构建并安装: $ sudo make && sudo make install

  5. 使用以下方法安装软件包: $ pip3 install package_name

Step by step guide to install Python 3.6 and pip3 in Ubuntu

  1. Install the necessary packages for Python and ssl: $ sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

  2. Download and unzip “Python-3.6.8.tar.xz” from https://www.python.org/ftp/python/ into your home directory.

  3. Open terminal in that directory and run: $ ./configure

  4. Build and install: $ make && sudo make install

  5. Install packages with: $ pip3 install package_name

Disclaimer: The above commands are not tested in Ubuntu 20.04 LTS.


回答 1

如果您使用的是Red Hat / CentOS:

# To allow for building python ssl libs
yum install openssl-devel
# Download the source of *any* python version
cd /usr/src
wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz
tar xf Python-3.6.2.tar.xz 
cd Python-3.6.2

# Configure the build w/ your installed libraries
./configure

# Install into /usr/local/bin/python3.6, don't overwrite global python bin
make altinstall

If you are on Red Hat/CentOS:

# To allow for building python ssl libs
yum install openssl-devel
# Download the source of *any* python version
cd /usr/src
wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz
tar xf Python-3.6.2.tar.xz 
cd Python-3.6.2

# Configure the build w/ your installed libraries
./configure

# Install into /usr/local/bin/python3.6, don't overwrite global python bin
make altinstall

回答 2

如果您使用Windows并使用anaconda,则对我有用

我尝试了许多其他无效的解决方案(环境PATH变量更改…)

该问题可能是由其他软件放置在Windows \ System32文件夹中的DLL(例如libcrypto-1_1-x64.dll或libssl-1_1-x64.dll或其他)引起的。

该修补程序是从https://slproweb.com/products/Win32OpenSSL.html安装openSSL的,它将dll替换为较新的版本。

If you are on Windows and use anaconda this worked for me:

I tried a lot of other solutions which did not work (Environment PATH Variable changes …)

The problem can be caused by DLLs in the Windows\System32 folder (e.g. libcrypto-1_1-x64.dll or libssl-1_1-x64.dll or others) placed there by other software.

The fix was installing openSSL from https://slproweb.com/products/Win32OpenSSL.html which replaces the dlls by more recent versions.


回答 3

我在OSX 10.11上遇到了类似的问题,原因是安装了memcached,它在3.6之上安装了python 3.7。

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

花了几个小时取消openssl的链接,重新安装,更改路径..无济于事。将openssl版本从改回较旧的版本可以达到目的:

brew switch openssl 1.0.2e

我在互联网上的任何地方都没有看到这个建议。希望它能为某人服务。

I had a similar problem on OSX 10.11 due to installing memcached which installed python 3.7 on top of 3.6.

WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

Spent hours on unlinking openssl, reinstalling, changing paths.. and nothing helped. Changing openssl version back from to older version did the trick:

brew switch openssl 1.0.2e

I did not see this suggestion anywhere in internet. Hope it serves someone.


回答 4

同意mastaBlasta的回答。为我工作。我遇到了与主题描述相同的问题。

环境:MacOS Sierra。我用自制的。

我的解决方案:

  1. 通过以下方式重新安装openssl brew uninstall openssl; brew install openssl
  2. 根据Homebrew提供的提示,执行以下操作:

    echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
    export LDFLAGS="-L/usr/local/opt/openssl/lib"
    export CPPFLAGS="-I/usr/local/opt/openssl/include"

Agree with the answer by mastaBlasta. Worked for me. I encountered the same problem as the topic description.

Environment: MacOS Sierra. And I use Homebrew.

My solution:

  1. Reinstall openssl by brew uninstall openssl; brew install openssl
  2. According to the hints given by Homebrew, do the following:

    echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
    export LDFLAGS="-L/usr/local/opt/openssl/lib"
    export CPPFLAGS="-I/usr/local/opt/openssl/include"
    

回答 5

在Ubuntu中,这可以帮助:

cd Python-3.6.2
./configure --with-ssl
make
sudo make install

In Ubuntu, this can help:

cd Python-3.6.2
./configure --with-ssl
make
sudo make install

回答 6

降级openssl对我有用

brew switch openssl 1.0.2s

Downgrading openssl worked for me,

brew switch openssl 1.0.2s

回答 7

该问题可能是由于缺少库引起的。

在安装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的更多信息

The problem probably caused by library missing.

Before you install python 3.6, make sure you install all the libraries required for 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

More information in How to Install Python 3.6.0 on Ubuntu & LinuxMint


回答 8

如果您在OSX上并且已经从源代码编译了python:

使用brew安装openssl brew install openssl

确保遵循brew给您的有关设置CPPFLAGS和的说明LDFLAGS。就我而言,我使用的是openssl@1.1brew公式,并且在python构建过程中需要以下3个设置才能正确链接到我的SSL库:

export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"
export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"

假设库安装在该位置。

If you are on OSX and have compiled python from source:

Install openssl using brew brew install openssl

Make sure to follow the instructions brew gives you about setting your CPPFLAGS and LDFLAGS. In my case I am using the openssl@1.1 brew formula and I need these 3 settings for the python build process to correctly link to my SSL library:

export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"
export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"

Assuming the library is installed at that location.


回答 9

我在Windows 10上遇到了同样的问题。我的非常具体的问题是由于安装了Anaconda。我安装了Anaconda并在路径下Path/to/Anaconda3/出现了python.exe。因此,我完全没有安装python,因为Anaconda包含python。使用pip安装软件包时,我发现了相同的错误报告pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

解决方案如下:

1)您可以在官方网站上再次下载python

2)导航到目录 "Python 3.7 (64-bit).lnk"位于

3)import sslexit()

4)例如输入cmd "Python 3.7 (64-bit).lnk" -m pip install tensorflow

在这里,您都准备好了。

I encountered the same problem on windows 10. My very specific issue is due to my installation of Anaconda. I installed Anaconda and under the path Path/to/Anaconda3/, there comes the python.exe. Thus, I didn’t install python at all because Anaconda includes python. When using pip to install packages, I found the same error report, pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available..

The solution was the following:

1) you can download python again on the official website;

2) Navigate to the directory where "Python 3.7 (64-bit).lnk"is located

3) import ssl and exit()

4) type in cmd, "Python 3.7 (64-bit).lnk" -m pip install tensorflow for instance.

Here, you’re all set.


回答 10

如果您使用的是Windows和使用Anaconda你可以尝试在Python提示符,而非cmd.exe运行“PIP安装…”命令,为用户willliu1995表明这里。对于我来说,这是最快的解决方案,不需要安装其他组件。

If you are on Windows and use Anaconda you can try running “pip install …” command in Anaconda Prompt instead of cmd.exe, as user willliu1995 suggests here. This was the fastest solution for me, that does not require installation of additional components.


回答 11

我尝试了很多方法来解决此问题,但都没有解决。我目前在Windows 10上。

唯一有效的是:

  • 卸载Anaconda
  • 卸载Python(我使用的是版本3.7.3)
  • 再次安装Python(请记住选择自动添加到PATH的选项)

然后,我使用PIP下载了我需要的所有库…并开始工作!

不知道为什么,或者问题是否与水蟒有关。

I tried A LOT of ways to solve this problem and none solved. I’m currently on Windows 10.

The only thing that worked was:

  • Uninstall Anaconda
  • Uninstall Python (i was using version 3.7.3)
  • Install Python again (remember to check the option to automatically add to PATH)

Then I’ve downloaded all the libs I needed using PIP… and worked!

Don’t know why, or if the problem was somehow related to Anaconda.


回答 12

对于osx brew用户

我的问题似乎与我的python安装有关,并且通过重新安装python3和pip很快得到解决。我认为它在操作系统更新后开始出现异常,但是谁知道(目前我在Mac OS 10.14.6上)

brew reinstall python3 --force
# setup pip
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
# installa pkg successfully 
pip install pandas

for osx brew users

my issue appeared related to my python installation and was quickly resolved by re-installing python3 and pip. i think it started misbehaving after an OS update but who knows (at this time I am on Mac OS 10.14.6)

brew reinstall python3 --force
# setup pip
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
# installa pkg successfully 
pip install pandas

回答 13

您可以执行以下两个操作之一:

  1. 在安装Anaconda时,选择将Anaconda添加到path的选项。

要么

  1. 从Anaconda的安装文件夹中找到这些(完整)路径,并将它们添加到环境变量中

\ Anaconda

\ Anaconda \ Library \ mingw-w64 \ bin

\ Anaconda \ Library \ usr \ bin

\ Anaconda \ Library \ bin

\ Anaconda \脚本

\ anaconda \ Library

\ anaconda \ condabin

将以上路径添加到“ Path”系统变量中,它应该不再显示错误:)

You can do either of these two:

  1. While installing Anaconda, select the option to add Anaconda to the path.

or

  1. Find these (complete) paths from your installation folder of Anaconda and add them to the environment variable :

\Anaconda

\Anaconda\Library\mingw-w64\bin

\Anaconda\Library\usr\bin

\Anaconda\Library\bin

\Anaconda\Scripts

\anaconda\Library

\anaconda\condabin

Add the above paths to the “Path” system variable and it should show the error no more :)


回答 14

我遇到了同样的问题,可以通过以下步骤解决:

sudo yum install -y libffi-devel
sudo yum install openssl-devel
cd /usr/src
sudo wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tar.xz
sudo tar xf Python-3.7.1.tar.xz
cd Python-3.7.1
sudo ./configure --enable-optimizations
# Install into /usr/local/bin/python3.7, don't overwrite global python bin
sudo make altinstall

根据烫发的不同,您可能不需要sudo。

Results:
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-10.0.1 setuptools-39.0.1

现在应该可以运行了

python3.7 -V 

pip3.7 -V

安装软件包时:

pip3.7 install pandas

或根据权限,还可以添加–user标志,如下所示:

pip3.7 install pandas --user

I was having the same issue and was able to resolve with the following steps:

sudo yum install -y libffi-devel
sudo yum install openssl-devel
cd /usr/src
sudo wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tar.xz
sudo tar xf Python-3.7.1.tar.xz
cd Python-3.7.1
sudo ./configure --enable-optimizations
# Install into /usr/local/bin/python3.7, don't overwrite global python bin
sudo make altinstall

depending on perms, you may not need sudo.

Results:
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-10.0.1 setuptools-39.0.1

should now be able to run

python3.7 -V 

and

pip3.7 -V

When installing packages:

pip3.7 install pandas

or depending on perms, you can also add the –user flag like so:

pip3.7 install pandas --user

回答 15

ssl模块是TLS / SSL包装器,用于访问Operation Sytem(OS)套接字(Lib / ssl.py)。因此,当ssl模块不可用时,很可能您没有安装OS OpenSSL库,或者在安装Python时找不到这些库。假设是一种较晚的情况(又名:您已经安装了OpenSSL,但是在安装Python时未正确链接它们)。

我还将假设您是从源代码安装的。如果要从二进制文件(即Window .exe文件)或软件包(Mac .dmg或Ubuntu apt)进行安装,则安装过程将无济于事。

在配置python安装的步骤中,您需要指定OS OpenSSL用于链接的位置:

# python 3.8 beta
./configure --with-openssl="your_OpenSSL root"

那么,在哪里可以找到已安装的OpenSSL目录?

# ubuntu 
locate ssl.h | grep '/openssl/ssl.h'

/home/user/.linuxbrew/Cellar/openssl/1.0.2r/include/openssl/ssl.h
/home/user/envs/py37/include/openssl/ssl.h
/home/user/miniconda3/envs/py38b3/include/openssl/ssl.h
/home/user/miniconda3/include/openssl/ssl.h
/home/user/miniconda3/pkgs/openssl-1.0.2s-h7b6447c_0/include/openssl/ssl.h
/home/user/miniconda3/pkgs/openssl-1.1.1b-h7b6447c_1/include/openssl/ssl.h
/home/user/miniconda3/pkgs/openssl-1.1.1c-h7b6447c_1/include/openssl/ssl.h
/usr/include/openssl/ssl.h

您的系统可能与我的系统不同,但是正如您在此处看到的,我安装了许多不同的openssl库。在撰写本文时,python 3.8期望openssl 1.0.2或1.1:

Python需要具有X509_VERIFY_PARAM_set1_host()的OpenSSL 1.0.2或1.1兼容libssl。

因此,您将需要验证可用于链接的已安装库中的哪一个,例如

/usr/bin/openssl version

OpenSSL 1.0.2g  1 Mar 2016
./configure --with-openssl="/usr"
make && make install

您可能需要尝试一些或安装新的库,以找到适用于您的Python和OS的库。

The ssl module is a TLS/SSL wrapper for accessing Operation Sytem (OS) socket (Lib/ssl.py). So when ssl module is not available, chances are that you either don’t have OS OpenSSL libraries installed, or those libraries were not found when you install Python. Let assume it is a later case (aka: you already have OpenSSL installed, but they are not correctly linked when installing Python).

I will also assume you are installing from source. If you are installing from binary (ie: Window .exe file), or package (Mac .dmg, or Ubuntu apt), there is not much you can do with the installing process.

During the step of configuring your python installation, you need to specify where the OS OpenSSL will be used for linking:

# python 3.8 beta
./configure --with-openssl="your_OpenSSL root"

So where will you find your installed OpenSSL directory?

# ubuntu 
locate ssl.h | grep '/openssl/ssl.h'

/home/user/.linuxbrew/Cellar/openssl/1.0.2r/include/openssl/ssl.h
/home/user/envs/py37/include/openssl/ssl.h
/home/user/miniconda3/envs/py38b3/include/openssl/ssl.h
/home/user/miniconda3/include/openssl/ssl.h
/home/user/miniconda3/pkgs/openssl-1.0.2s-h7b6447c_0/include/openssl/ssl.h
/home/user/miniconda3/pkgs/openssl-1.1.1b-h7b6447c_1/include/openssl/ssl.h
/home/user/miniconda3/pkgs/openssl-1.1.1c-h7b6447c_1/include/openssl/ssl.h
/usr/include/openssl/ssl.h

Your system may be different than mine, but as you see here I have many different installed openssl libraries. As the time of this writing, python 3.8 expects openssl 1.0.2 or 1.1:

Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host().

So you would need to verify which of those installed libraries that you can use for linking, for example

/usr/bin/openssl version

OpenSSL 1.0.2g  1 Mar 2016
./configure --with-openssl="/usr"
make && make install

You may need to try a few, or install a new, to find the library that would work for your Python and your OS.


回答 16

在使用Mac的情况下,我删除了 /Applications/Python 3.7。因为我已经有了Python3.7brew install python3

但这是信息的触发

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

我在情况下所做的

  1. 我再次下载了macOS 64位安装程序,并进行了安装。
  2. 双击/Applications/Python3.6/Install Certificates.command/Applications/Python3.6/Update Shell Profile.command
  3. 重新启动Mac
  4. 我不确定但可能对成功有所贡献pip.conf。请参阅pip安装失败

In my case with using Mac, I deleted /Applications/Python 3.7. because I already had Python3.7 by brew install python3 .

But it was a trigger of the message

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

What I did in my situation

  1. I downloaded macOS 64-bit installer again, and installed.
  2. Double click /Applications/Python3.6/Install Certificates.command and /Applications/Python3.6/Update Shell Profile.command.
  3. Reboot mac
  4. And I am not sure but possibly contributed to succeed is pip.conf. See pip install fails.

回答 17

我终于解决了这个问题。这些是我的环境的详细信息:
要安装的Python版本:3.6.8
操作系统:Ubuntu 16.04.6 LTS
根访问权限:否

有些人建议安装libssl-dev,但对我而言不起作用。我点击此链接,并对其进行了修复!
简而言之,我下载,提取,构建和安装OpenSSL(openssl-1.1.1b.tar.gz)。然后,我通过该链接修改.bashrc文件。 接下来,我下载并解压缩Python-3.6.8.tgz。我编辑Modules / Setup.dist来修改SSL路径(#211周围的行)。我做了,和。最后,我修改了。请注意,我没有包含在中。
./configure --prefix=$HOME/opt/python-3.6.8makemake install.bashrc--enable-optimizations./configure

I finally solve this issue. These are the detail of my env:
Version of Python to install: 3.6.8
OS: Ubuntu 16.04.6 LTS
Root access: No

Some people suggest to install libssl-dev, but it did not work for me. I follow this link and I fixed it!
In short, I download, extract, build, and install OpenSSL (openssl-1.1.1b.tar.gz). Then, I modify .bashrc file follow this link.
Next, I download and extract Python-3.6.8.tgz. I edit Modules/Setup.dist to modify SSL path (lines around #211). I did ./configure --prefix=$HOME/opt/python-3.6.8, make and make install. Last, I modify my .bashrc. Notice that I do not include --enable-optimizations in ./configure.


回答 18

在macOS上,使用以下命令配置python 3.8.1将解决此问题,我认为它也可以在Linux上运行。

./configure --enable-optimizations --with-openssl=/usr/local/opt/openssl@1.1/

根据您的系统更改dir参数。

On macos, configure python 3.8.1 with the command below will solve the problem, i think it would also work on Linux.

./configure --enable-optimizations --with-openssl=/usr/local/opt/openssl@1.1/

change the dir parameter based on your system.


回答 19

如果您使用的是OSX,以防其他解决方案对您不起作用(就像我一样)。

您可以尝试卸载python3并升级pip3

brew uninstall --ignore-dependencies python3
pip3 install --upgrade pip   

这对我有用;)

If you are on OSX and in case the other solutions didn’t work for you (just like me).

You can try uninstalling python3 and upgrade pip3

brew uninstall --ignore-dependencies python3
pip3 install --upgrade pip   

This worked for me ;)


回答 20

(在Windows上不!)

这使我把头发扯了一个星期,所以我希望这可以帮助某人

除了重新安装Anaconda和/或Jupyter外,我尝试了所有尝试。

建立

  • AWS Linux
  • 手动安装的Anaconda 3-5.3.0
  • Python3(3.7)在anaconda内部运行(即./anaconda3/bin/python
  • 也有/usr/bin/python/usr/bin/python3(但大部分工作在Jupyter的终端做这些没有被使用)

固定

在Jupyter的终端中:

cp /usr/lib64/libssl.so.10 ./anaconda3/lib/libssl.so.1.0.0

cp /usr/lib64/libcrypto.so.10 ./anaconda3/lib/libcrypto.so.1.0.0

是什么触发了这个?

所以,这一切都是有效的,直到我尝试做一个 conda install conda-forge

我不确定发生了什么,但是conda必须已更新 openssl在包装盒上(我猜是这样),所以在此之后,一切都坏了。

基本上,不认得我,畅达了OpenSSL更新,但不知何故,删除旧的图书馆,取而代之的是libssl.so.1.1libcrypto.so.1.1

我猜Python3是为了寻找而编译的 libssl.so.1.0.0

最后,诊断的关键是:

python -c "import ssl; print (ssl.OPENSSL_VERSION)"

给出了线索 library "libssl.so.1.0.0" not found

我做出的巨大假设是yumssl 的版本与conda版本,因此只要重命名共享库就可以了,而且确实如此。

我的另一个解决方案是重新编译python,重新安装anaconda等,但是最后我很高兴我不需要。

希望这可以帮助你们。

(NOT on Windows!)

This made me tear my hair out for a week, so I hope this will help someone

I tried everything short of re-installing Anaconda and/or Jupyter.

Setup

  • AWS Linux
  • Manually installed Anaconda 3-5.3.0
  • Python3 (3.7) was running inside anaconda (ie, ./anaconda3/bin/python)
  • there was also /usr/bin/python and /usr/bin/python3 (but these were not being used as most of the work was done in Jupyter’s terminal)

Fix

In Jupyter’s terminal:

cp /usr/lib64/libssl.so.10 ./anaconda3/lib/libssl.so.1.0.0

cp /usr/lib64/libcrypto.so.10 ./anaconda3/lib/libcrypto.so.1.0.0

What triggered this?

So, this was all working until I tried to do a conda install conda-forge

I’m not sure what happened, but conda must have updated openssl on the box (I’m guessing) so after this, everything broke.

Basically, unknown to me, conda had updated openssl, but somehow deleted the old libraries and replaced it with libssl.so.1.1 and libcrypto.so.1.1.

Python3, I guess, was compiled to look for libssl.so.1.0.0

In the end, the key to diagnosis was this:

python -c "import ssl; print (ssl.OPENSSL_VERSION)"

gave the clue library "libssl.so.1.0.0" not found

The huge assumption I made is that the yum version of ssl is the same as the conda version, so just renaming the shared object might work, and it did.

My other solution was to re-compile python, re-install anaconda, etc, but in the end I’m glad I didn’t need to.

Hope this helps you guys out.


回答 21

pyenv用于管理Mac OS Catalina上的python安装的情况下,我必须先openssl使用brew 安装,然后再运行pyenv install 3.7.8,这似乎是使用opensslfrom homebrew 来构建python安装的(甚至在安装输出中也是如此)。然后pyenv global 3.7.8,我不在了。

In the case of using pyenv to manage python installations on Mac OS Catalina, I had to install openssl with brew first and then after that run pyenv install 3.7.8 which seemed to build the python installation using the openssl from homebrew (it even said as such in the installation output). Then pyenv global 3.7.8 and I was away.


回答 22

我可以通过更新此文件中的python版本来解决此问题。pyenv:未安装版本“ 3.6.5”(由/Users/taruntarun/.python-version设置)尽管我安装了最新版本,但我的命令仍在使用旧版本3.6.5

移至版本3.7.3

I was able to fix this by updating the python version in this file. pyenv: version `3.6.5′ is not installed (set by /Users/taruntarun/.python-version) Though i had the latest version installed, my command was still using old version 3.6.5

Moving to version 3.7.3


回答 23

最近两天我遇到了同样的问题,现在才解决。

我曾试图使用--trust-host与该选项DigiCert_High_Assurance_EV_Root_CA.pem没有工作,我无法安装SSL模块(它告诉它不能被安装Python版本大于2.6),设置$PIP_CERT可变没修好,要么,我不得不libssl1.0.2libssl1.0.0安装。还值得一提的是,我没有~/.pip/pip.conf文件,创建文件也无法解决该错误。

最终解决问题的是make再次安装了python3.6 。从网站上下载的Python-3.6.0.tgz,跑configure那么makemake testmake install。希望对你有效。

I was having the same problem for the last two days and only have fixed it right now.

I had tried to use --trust-host option with the DigiCert_High_Assurance_EV_Root_CA.pem did not work, I couldn’t install the ssl module (It tells it cannot be installed for python versions greater than 2.6), setting the $PIP_CERT variable didn’t fix it either and I had libssl1.0.2 and libssl1.0.0 installed. Also worth mentioning I didn’t had a ~/.pip/pip.conf file, and creating it didn’t solve the bug either.

What finally solved it, was installing python3.6 with make again. Download the Python-3.6.0.tgz from the website, run configure then make, make test and make install. Hope it works for you.


回答 24

Python文档实际上是很明确的,按照指示做了,而其他的答案我发现这里并没有解决这个问题的工作。

  1. 首先,使用例如版本3.6.2 https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz从源安装python3.xx。

  2. 确保通过运行安装了openssl brew install openssl

  3. 解压缩并移至python目录: tar xvzf Python-3.6.2.tar.xz && cd Python-3.6.2

  4. 然后,如果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个作业)

The python documentation is actually very clear, and following the instructions did the job whereas other answers I found here were not fixing this issue.

  1. first, install python 3.x.x from source using, for example with version 3.6.2 https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz

  2. make sure you have openssl installed by running brew install openssl

  3. unzip it and move to the python directory: tar xvzf Python-3.6.2.tar.xz && cd Python-3.6.2

  4. then if the python version is < 3.7, run

CPPFLAGS="-I$(brew --prefix openssl)/include" \ LDFLAGS="-L$(brew --prefix openssl)/lib" \ ./configure --with-pydebug 5. finallly, run make -s -j2 (-s is the silent flag, -j2 tells your machine to use 2 jobs)


回答 25

我在尝试在ubuntu14.04机器上安装python3.7时遇到了同样的问题。问题是我在PKG_CONFIG_PATH和LD_LIBRARY_PATH中有一些自定义文件夹,这阻止了python构建过程来找到系统openssl库。

因此,请尝试清除它们并查看会发生什么情况:

export PKG_CONFIG_PATH=""
export LD_LIBRARY_PATH=""

I had the same issue trying to install python3.7 on an ubuntu14.04 machine. The issue was that I had some custom folders in my PKG_CONFIG_PATH and in my LD_LIBRARY_PATH, which prevented the python build process to find the system openssl libraries.

so try to clear them and see what happens:

export PKG_CONFIG_PATH=""
export LD_LIBRARY_PATH=""

回答 26

好的,对此的最新答案是,截至目前,请勿使用Python 3.8,仅使用3.7或更小版本,因为大多数库由于上述错误而无法安装

Ok the latest answer to this, as of now don’t use Python 3.8, use only 3.7 or less , because of most of the libraries fail to install with the above error


声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。