Failed to build these modules: _ctypes && Failed to build these modules: _curses

Python编译问题:解决OpenSSL和依赖模块错误的步骤,
文章讲述了作者在编译Python过程中遇到OpenSSL和相关模块错误,通过一系列apt-get命令安装必要的开发工具和库,包括libssl-dev,libffi-dev等,并强调了正确执行makeclean和./configure的顺序。最终成功安装并验证了Python版本。
部署运行你感兴趣的模型镜像

问题描述

本人今天在编译Python代码时遇到了这样的问题,过程大概是先用wget指令下载Python对应版本的源代码,然后用tar指令解压缩,之后cd到解压后得到的源代码目录下执行命令./config进行预编译,然后在make编译,之后通过make install命令安装,整个过程可以参考这篇博客
期间遇到了OpenSSL的报错

Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_P

你需要参考其他博客或者这篇,个人感觉我看的这篇里面的一些什么软连接之类的操作既看不懂也没啥必要,我没管也操作好了,我们主要是一个目的:下载和安装OpenSSL,个人认为比较重点是以下截图的几步:
在这里插入图片描述
之后我们就可以通过openssl version指令直接在控制台查看openssl的版本了。问题就出在接下来make 的时候,新报错是

Failed to build these modules: 
_ctypes 
or
Failed to build these modules: 
_curses

在这里插入图片描述

如何解决这个问题的

参考博客一博客二,归纳一下
需要运行一个全体安装的指令。下面的指令一个都不能少:

sudo apt-get update
 
sudo apt-get upgrade
 
sudo apt-get dist-upgrade
 
sudo apt-get install build-essential python3-dev python3-setuptools python3-pip python3-smbus
 
sudo apt-get install build-essential libncursesw5-dev libgdbm-dev libc6-dev
 
sudo apt-get install zlib1g-dev libsqlite3-dev tk-dev
 
sudo apt-get install libssl-dev openssl
 
sudo apt-get install libffi-dev

sudo apt-get install libffi-dev libbz2-dev libncursesw5-dev 
sudo apt-get install libgdbm-dev python-lzma liblzma-dev libsqlite3-dev 
sudo apt-get install  tk-dev uuid-dev libreadline-dev

根据博客二,我们有这样的了解:

本人验证,每一个模块对应的安装包名(sudo apt-get install 安装包名)如下
模块_ctypes,安装包名libffi-dev
模块_bz2,安装包名libbz2-dev
模块_curses和_curses_panel,安装包名libncursesw5-dev
模块_dbm和_gdbm,安装包名libgdbm-dev
模块_lzma,安装包名python-lzma和liblzma-dev
模块_sqlite3,安装包名libsqlite3-dev
模块_tkinter,安装包名tk-dev
模块_uuid,安装包名uuid-dev
模块readline,安装包名libreadline-dev
————————————————
版权声明:本文为优快云博主「shenweihong」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.youkuaiyun.com/shenweihong/article/details/123541087

直呼作者大佬,全部执行以后再从make clean./configure开始,而不是从make指令开始,不要偷懒,知道吗?
那么我们依次再执行make clean->./configure --prefix=/usr/local/python3 -> make -j4 -> make install
(注:./configure--prefix参数是用于指定安装目录的,可根据需要添加)
成功编译,成功安装,最后可以通过指令python --version指令查看成功安装的python版本。
至此完结撒花!!!

您可能感兴趣的与本文相关的镜像

Python3.11

Python3.11

Conda
Python

Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

stellaechen@STELLAECHEN-MC1 ~ % make make: *** No targets specified and no makefile found. Stop. stellaechen@STELLAECHEN-MC1 ~ % cd download stellaechen@STELLAECHEN-MC1 download % cd Python-2.7.13 stellaechen@STELLAECHEN-MC1 Python-2.7.13 % make running build running build_ext building '_Qt' extension gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/stellaechen/download/Python-2.7.13/Mac/Include -I. -IInclude -I./Include -I/usr/local/include -I/Users/stellaechen/download/Python-2.7.13/Include -I/Users/stellaechen/download/Python-2.7.13 -c /Users/stellaechen/download/Python-2.7.13/Mac/Modules/qt/_Qtmodule.c -o build/temp.macosx-15.4-arm64-2.7/Users/stellaechen/download/Python-2.7.13/Mac/Modules/qt/_Qtmodule.o -Wno-deprecated-declarations /Users/stellaechen/download/Python-2.7.13/Mac/Modules/qt/_Qtmodule.c:28003:15: warning: variable 'm' set but not used [-Wunused-but-set-variable] 28003 | PyObject *m; | ^ 1 warning generated. gcc -bundle -undefined dynamic_lookup build/temp.macosx-15.4-arm64-2.7/Users/stellaechen/download/Python-2.7.13/Mac/Modules/qt/_Qtmodule.o -L/usr/local/lib -o build/lib.macosx-15.4-arm64-2.7/_Qt.so -framework QuickTime -framework Carbon ld: framework 'QuickTime' not found clang: error: linker command failed with exit code 1 (use -v to see invocation) building '_tkinter' extension gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DWITH_APPINIT=1 -I/System/Library/Frameworks/Tcl.framework/Headers -I/System/Library/Frameworks/Tcl.framework/Versions/Current/PrivateHeaders -I/System/Library/Frameworks/Tk.framework/Headers -I/System/Library/Frameworks/Tk.framework/Versions/Current/PrivateHeaders -I/usr/X11R6/include -I/Users/stellaechen/download/Python-2.7.13/Mac/Include -I. -IInclude -I./Include -I/usr/local/include -I/Users/stellaechen/download/Python-2.7.13/Include -I/Users/stellaechen/download/Python-2.7.13 -c /Users/stellaechen/download/Python-2.7.13/Modules/_tkinter.c -o build/temp.macosx-15.4-arm64-2.7/Users/stellaechen/download/Python-2.7.13/Modules/_tkinter.o -framework Tk clang: warning: -framework Tk: 'linker' input unused [-Wunused-command-line-argument] In file included from /Users/stellaechen/download/Python-2.7.13/Modules/_tkinter.c:71: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/tk.h:86:11: fatal error: 'X11/Xlib.h' file not found 86 | # include <X11/Xlib.h> | ^~~~~~~~~~~~ 1 error generated. building '_ctypes' extension gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I_ctypes/darwin -I/Users/stellaechen/download/Python-2.7.13/Mac/Include -I/Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/libffi_osx/include -I/Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/libffi_osx/powerpc -I. -IInclude -I./Include -I/usr/local/include -I/Users/stellaechen/download/Python-2.7.13/Include -I/Users/stellaechen/download/Python-2.7.13 -c /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/_ctypes.c -o build/temp.macosx-15.4-arm64-2.7/Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/_ctypes.o -DMACOSX In file included from /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/_ctypes.c:113: /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/libffi_osx/include/ffi.h:65:3: error: "Unsupported MacOS X CPU type" 65 | # error "Unsupported MacOS X CPU type" | ^ In file included from /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/_ctypes.c:113: In file included from /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/libffi_osx/include/ffi.h:73: /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/libffi_osx/include/ffitarget.h:12:2: error: "Unsupported CPU type" 12 | #error "Unsupported CPU type" | ^ In file included from /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/_ctypes.c:113: In file included from /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/libffi_osx/include/ffi.h:74: /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/libffi_osx/include/fficonfig.h:51:2: error: "Unknown CPU type" 51 | #error "Unknown CPU type" | ^ In file included from /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/_ctypes.c:113: /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/libffi_osx/include/ffi.h:171:5: error: unknown type name 'ffi_abi' 171 | ffi_abi abi; | ^ /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/libffi_osx/include/ffi.h:193:2: error: unknown type name 'ffi_sarg' 193 | ffi_sarg sint; | ^ /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/libffi_osx/include/ffi.h:194:2: error: unknown type name 'ffi_arg' 194 | ffi_arg uint; | ^ /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/libffi_osx/include/ffi.h:307:11: error: unknown type name 'ffi_abi' 307 | ffi_abi abi, | ^ In file included from /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/_ctypes.c:129: /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/ctypes.h:99:5: error: unknown type name 'ffi_closure' 99 | ffi_closure *pcl_write; /* the C callable, writeable */ | ^ 8 errors generated. Python build finished, but the necessary bits to build these modules were not found: _bsddb _curses _curses_panel _sqlite3 _ssl bsddb185 bz2 dbm dl gdbm imageop linuxaudiodev nis ossaudiodev readline spwd sunaudiodev zlib To find the necessary bits, look in setup.py in detect_modules() for the module's name. Failed to build these modules: _ctypes _Qt _tkinter running build_scripts stellaechen@STELLAECHEN-MC1 Python-2.7.13 %
07-05
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值