一、pyenv安装python,出现以下错误:BUILD FAILED (Ubuntu 20.04 using python-build 2.3.36-21-g7e550e31) Inspect or clean up the working tree at /tmp/python-build.20240326131817.1499499 Results logged to /tmp/python-build.20240326131817.1499499.log Last 10 log lines: File "/tmp/python-build.20240326131817.1499499/Python-3.10.14/Lib/ensurepip/__ return _bootstrap( File "/tmp/python-build.20240326131817.1499499/Python-3.10.14/Lib/ensurepip/__ return _run_pip([*args, *_PACKAGE_NAMES], additional_paths) File "/tmp/python-build.20240326131817.1499499/Python-3.10.14/Lib/ensurepip/__ return subprocess.run(cmd, check=True).returncode File "/tmp/python-build.20240326131817.1499499/Python-3.10.14/Lib/subprocess.p raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['/tmp/python-build.20240326131817.14994ny.whl\', \'/tmp/tmpb4h_j2fk/pip-23.0.1-py3-none-any.whl\'] + sys.path\nsys.argvrunpy.run_module("pip", run_name="__main__", alter_sys=True)\n']' returned non-z make: *** [Makefile:1280: install] Error 1
-
清理构建目录: 删除
/tmp/目录下的所有 python-build.开头的文件,
可能会有助于解决这个问题。这将清除之前的构建尝试,并允许pyenv
重新开始构建过程。 -
确保构建依赖项安装: 重新安装以下库,如
build-essential
、libssl-dev
、zlib1g-dev
、libbz2-dev
、libreadline-dev
、libsqlite3-dev
、wget
、curl
等。
二、pyenv安装python,出现以下错误:Traceback (most recent call last): File "<string>", line 1, in <module> File "/home/xtjie/.pyenv/versions/3.10.14/lib/python3.10/lzma.py", line 27, in <module> from _lzma import * ModuleNotFoundError: No module named '_lzma' WARNING: The Python lzma extension was not compiled. Missing the lzma lib? Installed Python-3.10.14 to /home/xtjie/.pyenv/versions/3.10.14
-
安装
liblzma-dev
包,这是开发版本的lzma
库,包含了编译_lzma
模块所需的头文件。sudo apt-get update sudo apt-get install -y liblzma-dev
-
重新编译 Python。如果你之前已经使用
pyenv
安装了 Python,你需要先删除旧的版本,然后再重新安装:pyenv uninstall 3.10.14
pyenv install 3.10.14
以上参考kimi大模型解决。