pyenv Python 3.11.5 在 Kubuntu 23.04 中安装失败

pyenv Python 3.11.5 在 Kubuntu 23.04 中安装失败

我正在使用zshoh-my-zsh。我正在做

➜  ~ pyenv install 3.11.5

输出为:

Downloading Python-3.11.5.tar.xz...
-> https://www.python.org/ftp/python/3.11.5/Python-3.11.5.tar.xz
Installing Python-3.11.5...
Traceback (most recent call last):                                        
  File "<string>", line 1, in <module>
  File "/home/irem/.pyenv/versions/3.11.5/lib/python3.11/ctypes/__init__.py", line 8, in <module>
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
WARNING: The Python ctypes extension was not compiled. Missing the libffi lib?
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/irem/.pyenv/versions/3.11.5/lib/python3.11/ssl.py", line 100, 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.
https://github.com/pyenv/pyenv/wiki/Common-build-problems


BUILD FAILED (Ubuntu 23.04 using python-build 20180424)

Inspect or clean up the working tree at /tmp/python-build.20230902112800.123560
Results logged to /tmp/python-build.20230902112800.123560.log

Last 10 log lines:
    LD_LIBRARY_PATH=/tmp/python-build.20230902112800.123560/Python-3.11.5 ./python -E -m ensurepip \
            $ensurepip --root=/ ; \
fi
Looking in links: /tmp/tmpurefphym
Processing /tmp/tmpurefphym/setuptools-65.5.0-py3-none-any.whl
Processing /tmp/tmpurefphym/pip-23.2.1-py3-none-any.whl
Installing collected packages: setuptools, pip
  WARNING: The scripts pip3 and pip3.11 are installed in '/home/irem/.pyenv/versions/3.11.5/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-23.2.1 setuptools-65.5.0

我看到很多答案说python必须在某处使用别名,但我没有这样做。以下是我的.zshrc文件中的内容:

export ZSH="$HOME/.oh-my-zsh"
plugins=(git)

source $ZSH/oh-my-zsh.sh

# pyenv
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv virtualenv-init -)"

# alias nvim
alias vi="nvim"

至于各种oh-my-zsh配置文件,据我所知,它们都有默认选项。我个人没有改变任何东西。

我还要补充一点:

➜  ~ openssl version
OpenSSL 3.0.8 7 Feb 2023 (Library: OpenSSL 3.0.8 7 Feb 2023)
➜  ~ openssl version -d
OPENSSLDIR: "/usr/lib/ssl"

相关内容