使用自定义编译的Python使用pip进行安装无法使用SSL

时间:2017-04-05 15:57:19

标签: python ssl pip

我尝试使用pip安装Flask。我一直关注this tutorial,它指示我编译Python 3. pip install Flask给出错误,SSL模块不可用,然后无法安装Flask。

编译时,我必须sudo apt-get install zlib1g-dev来编译zlib。我是否还必须安装一些东西来编译SSL模块?

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

1 个答案:

答案 0 :(得分:1)

大多数现代Linux发行版(包括Mint)已经安装了Python 3,只运行python3。如果未安装,请使用sudo apt-get install python3(或您的发行版的等效文件)进行安装。你不应该自己编译。

创建一个virtualenv,然后在那里安装Flask。

mkdir myproject && cd myproject
python3 -m venv env
. env/bin/activate
pip install flask

如果出于某种原因,你仍然想自己编译它,那么就像你必须为zlib安装开发头一样,你必须对openssl(以及其他一些如果你想要标准版本)做同样的事情。 sudo apt-get install libssl-dev