You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用pyenv安装Python 3.10失败:依赖编译报错求助

安装Python 3.10 via pyenv失败:依赖模块(_curses、readline、_ssl)缺失

问题现象

使用pyenv安装Python 3.10时,安装器提示openssl、readline、ncurses依赖未完成编译,但同时显示python-build正在使用Homebrew提供的这些依赖。安装完成后,_curses、readline、_ssl模块缺失;执行pyenv doctor提示GNU readline未安装。

已尝试操作

按照官方Wiki《Common build problems》中的说明添加编译标志,执行命令如下:

CPPFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix readline)/include -I$(xcrun -show-sdk-path)/usr/include" LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib"
pyenv install 3.10

错误日志

pyenv install 3.10 报错日志

python-build: use openssl from homebrew
python-build: use readline from homebrew
Downloading Python-3.10.15.tar.xz...
-> https://www.python.org/ftp/python/3.10.15/Python-3.10.15.tar.xz
Installing Python-3.10.15...
python-build: use tcl-tk from homebrew
python-build: use readline from homebrew
python-build: use ncurses from homebrew
python-build: use zlib from xcode sdk
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/quan.nguyen/.pyenv/versions/3.10.15/lib/python3.10/curses/__init__.py", line 13, in <module>
    from _curses import *
ModuleNotFoundError: No module named '_curses'
WARNING: The Python curses extension was not compiled. Missing the ncurses lib?
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'readline'
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/quan.nguyen/.pyenv/versions/3.10.15/lib/python3.10/ssl.py", line 99, in <module>
    import _ssl             # if we can't import it, let the error propagate
ModuleNotFoundError: No module named '_ssl'
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

Please consult to the Wiki page to fix the problem.


BUILD FAILED (OS X 15.0 using python-build 2.4.13)

Inspect or clean up the working tree at /var/folders/f_/_mwchwz12xzbycp94nqvbdv5s9_ljk/T/python-build.20240919150807.79066
Results logged to /var/folders/f_/_mwchwz12xzbycp94nqvbdv5s9_ljk/T/python-build.20240919150807.79066.log

Last 10 log lines:
            $ensurepip --root=/ ; \
    fi
Looking in links: /var/folders/f_/_mwchwz12xzbycp94nqvbdv5s9_ljk/T/tmpklg5hx7t
Processing /private/var/folders/f_/_mwchwz12xzbycp94nqvbdv5s9_ljk/T/tmpklg5hx7t/setuptools-65.5.0-py3-none-any.whl
Processing /private/var/folders/f_/_mwchwz12xzbycp94nqvbdv5s9_ljk/T/tmpklg5hx7t/pip-23.0.1-py3-none-any.whl
Installing collected packages: setuptools, pip
  WARNING: The scripts pip3 and pip3.10 are installed in '/Users/quan.nguyen/.pyenv/versions/3.10.15/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  NOTE: The current PATH contains path(s) starting with `~`, which may not be expanded by all applications.
Successfully installed pip-23.0.1 setuptools-65.5.0

pyenv doctor 报错日志

❯ pyenv doctor
Cloning /Users/quan.nguyen/.pyenv/plugins/pyenv-doctor/bin/.....
Installing python-pyenv-doctor...
python-build: use tcl-tk from homebrew
python-build: use readline from homebrew
python-build: use ncurses from homebrew
python-build: use zlib from xcode sdk

BUILD FAILED (OS X 15.0 using python-build 2.4.13)

Inspect or clean up the working tree at /var/folders/f_/_mwchwz12xzbycp94nqvbdv5s9_ljk/T/python-build.20240919153937.2140
Results logged to /var/folders/f_/_mwchwz12xzbycp94nqvbdv5s9_ljk/T/python-build.20240919153937.2140.log

Last 10 log lines:
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether clang accepts -g... yes
checking for clang option to accept ISO C89... none needed
checking for rl_gnu_readline_p in -lreadline... no
configure: error: GNU readline is not installed.
make: *** No targets specified and no makefile found.  Stop.
Problem(s) detected while checking system.

已查阅官方文档但仍无法解决问题,寻求帮助。


内容的提问来源于stack exchange,提问作者Quan Nguyen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 04:47:09