Linux安装Python失败常见缺失依赖项

1._ctypes 模块构建失败

build correctly but finished with this message:

    Failed to build these modules:
    _ctypes   

解决
Are you using Ubuntu or other Linux distribution? This problem is because you didn’t install the dependency package.

You may first try to use the instruction at devguide:
http://cpython-devguide.readthedocs.io/setup.html#build-dependencies

Or, assume you have install build-essential and python3-dev …etc., maybe you lost to install libffi-dev, just simply apt-get install libffi-dev and rebuild to solve this problem.

  1. ssl 模块构建失败
Could not build the ssl module!
Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host().
LibreSSL 2.6.4 and earlier do not provide the necessary APIs, 
https://github.com/libressl-portable/portable/issues/381

解决
输入命令 openssl version 查看当前安装的openssl版本:

codedancing@Ubuntu:/usr/local/src/Python-3.7.6$ openssl version
OpenSSL 1.1.1d  10 Sep 2019

即使OpenSSL是最新版本,仍然需要重新安装OpenSSL:
(1)访问 OpenSSL官网 下载最新的 openssl 安装包
(2)解压安装包: sudo tar -zxf openssl-1.1.1d.tar.gz
(3)进入安装包依次执行:./configmakemake testmake install

  1. 缺失 zlib 相关工具包
zipimport.ZipImportError: can't decompress data; zlib not available
Makefile:1099: recipe for target 'install' failed
make: *** [install] Error 1

解决
安装 zlib 相关依赖包
sudo apt install zlibc zlib1g-dev

发布了21 篇原创文章 · 获赞 6 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/codedancing/article/details/103947858