树莓派4B,在debian12(bookworm)系统下,下载源码安装python3.12.2,按照README文件,执行:
On Unix, Linux, BSD, macOS, and Cygwin::
./configure
make
make test
sudo make install
This will install Python as python3
.
——————————————————————————-——————
在make阶段中,显示问题:
The necessary bits to build these optional modules were not found: _dbm
————————————————————————————————
根据随后的提示,在python3安装文件中找到configure.ac文件,打开,搜索 _dbm,可看到:
dnl check for _dbmmodule.c dependencies
dnl ndbm, gdbm_compat, libdb
AC_CHECK_HEADERS([ndbm.h], [
WITH_SAVE_ENV([
AC_SEARCH_LIBS([dbm_open], [ndbm gdbm_compat])
])
])
——————————————————————————————————————
根据上文提示,安装ndbm, gdbm_compat, libdb对应的库(笔者ndbm对应库已经安装好了,只缺乏后面两个),终端输入:
sudo apt-get install libgdbm-compat-dev libdb-dev
————————————————————————————————————
两个库文件安装完毕后,重新编译make,问题完美解决。