【发布时间】:2022-12-21 05:56:02
【问题描述】:
我在 Ubuntu 22.04.1 上,它带有自己的 python3.11,pip 可以完美运行。
如果我通过 apt-get (sudo apt-get install python3.10) 安装其他 python 版本,则相关的 pip 可以完美运行。
但是我刚刚从源代码安装了一个替代的 python 版本(3.7.9)(我不能为这个 python 版本使用 apt),执行以下操作
cd usr/lib
sudo wget https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz
sudo tar xzf Python-3.7.9.tg
cd Python-3.7.9
sudo ./configure --enable-optimizations
sudo make altinstall
Python3.7 工作正常,但是如果我尝试安装任何包(使用 pip3.7,或者在创建基于 python3.7 的 virtualenv 之后,使用 pip),我会收到以下警告
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
其次是错误
ERROR: Could not find a version that satisfies the requirement numpy (from versions: none)
ERROR: No matching distribution found for numpy
我确定我已经安装了 Openssl,因为其他版本的 python 不会用 pip 给出问题(我也可以在文件夹/etc/ssl 中看到 ssl)所以问题似乎只与 ssl 和 python 之间的链接有关从源安装.
有什么建议么?
【问题讨论】:
-
提示 1:当您真的不需要时,请避免使用
sudo。下载编译不需要sudo,make install才需要。 -
提示 2:观察
./configure的输出。是的,它很大而且很无聊。但这堆中隐藏着宝石。特别注意缺少库的问题。 -
提示 3:要编译 Python 的
_ssl.so模块,您需要 OpenSSL 开发文件(头文件和链接库)。我不是 100% 确定,但我认为你需要sudo apt install openssl-devel。清理之后,重新配置并重新编译 Python。像这样:sudo chown -R $USER . && make distclean && ./configure && make && sudo make altinstall -
对不起,是
sudo apt install libssl-dev -
谢谢,但在我的情况下 openssl 已经安装但是从源代码编译的 python 无法“看到”它(从 apt-get 安装的 python 没有这个问题),我想我找到了解决我的特定问题的方法,我贴在下面
标签: python-3.x ubuntu ssl pip openssl