我是 Linux 新手。当我尝试通过 pyenv 安装 python 时,出现此错误:
操作系统:Ubuntu 22.04
kev@kev-Modern-15-A5M:~$ pyenv install 3.8.13
Downloading Python-3.8.13.tar.xz...
-> https://www.python.org/ftp/python/3.8.13/Python-3.8.13.tar.xz
Installing Python-3.8.13...
WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?
Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems
BUILD FAILED (Ubuntu 22.04 using python-build 20180424)
Inspect or clean up the working tree at /tmp/python-build.20220629160539.201051
Results logged to /tmp/python-build.20220629160539.201051.log
Last 10 log lines:
./python -E -m ensurepip \
$ensurepip --root=/ ; \
fi
Looking in links: /tmp/tmppnia5_0_
Processing /tmp/tmppnia5_0_/setuptools-56.0.0-py3-none-any.whl
Processing /tmp/tmppnia5_0_/pip-22.0.4-py3-none-any.whl
Installing collected packages: setuptools, pip
WARNING: The scripts pip3 and pip3.8 are installed in '/home/kev/.pyenv/versions/3.8.13/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.
Successfully installed pip-22.0.4 setuptools-56.0.0
答案1
该问题是由 Homebrew 引起的,只需手动卸载并重新安装软件包即可,无需 Homebrew。
答案2
在 Ubuntu 22 LTS 上
使用 Pyenv 安装 Python 时缺少库问题
修复之前:
$> pyenv install 3.11.0
命令结果:
pyenv: /home/user/.pyenv/versions/3.11.0 already exists
continue with installation? (y/N) y
Downloading Python-3.11.0.tar.xz...
-> https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tar.xz
Installing Python-3.11.0...
WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
WARNING: The Python lzma extension was not compiled. Missing the lzma lib?
TLDR;
修复方法:
sudo apt-get install build-essential zlib1g-dev libffi-dev libssl-dev libbz2-dev libreadline-dev libsqlite3-dev liblzma-dev
结果
修复后:
$> pyenv install 3.11.0
命令结果:
pyenv: /home/user/.pyenv/versions/3.11.0 already exists
continue with installation? (y/N) y
Downloading Python-3.11.0.tar.xz...
-> https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tar.xz
Installing Python-3.11.0...
Installed Python-3.11.0 to /home/user/.pyenv/versions/3.11.0