使用 pyenv 安装 Python 3.11.1 的问题

eux*_*xxx 5 python ubuntu homebrew openssl pyenv

我尝试使用 Pyenv 安装 Python 3.11.1 并得到以下结果:

\n
\xe2\x9e\x9c  ~ pyenv install 3.11.1 \nDownloading Python-3.11.1.tar.xz...\n-> https://www.python.org/ftp/python/3.11.1/Python-3.11.1.tar.xz\nInstalling Python-3.11.1...\nTraceback (most recent call last):\n  File "<string>", line 1, in <module>\n  File "/home/eustignos/.pyenv/versions/3.11.1/lib/python3.11/ssl.py", line 100, in <module>\n    import _ssl             # if we can't import it, let the error propagate\n    ^^^^^^^^^^^\nModuleNotFoundError: No module named '_ssl'\nERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?\n\nPlease consult to the Wiki page to fix the problem.\nhttps://github.com/pyenv/pyenv/wiki/Common-build-problems\n\n\nBUILD FAILED (Ubuntu 22.10 using python-build 20180424)\n\nInspect or clean up the working tree at /tmp/python-build.20230112175103.128449\nResults logged to /tmp/python-build.20230112175103.128449.log\n\nLast 10 log lines:\n        LD_LIBRARY_PATH=/tmp/python-build.20230112175103.128449/Python-3.11.1 ./python -E -m ensurepip \\\n                $ensurepip --root=/ ; \\\nfi\nLooking in links: /tmp/tmpba6xv1b0\nProcessing /tmp/tmpba6xv1b0/setuptools-65.5.0-py3-none-any.whl\nProcessing /tmp/tmpba6xv1b0/pip-22.3.1-py3-none-any.whl\nInstalling collected packages: setuptools, pip\n  WARNING: The scripts pip3 and pip3.11 are installed in '/home/{user}/.pyenv/versions/3.11.1/bin' which is not on PATH.\n  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.\nSuccessfully installed pip-22.3.1 setuptools-65.5.0\n
Run Code Online (Sandbox Code Playgroud)\n
\n

OpenSSL 有 2 种不同的安装方式(使用 apt-latest for 22.10 和 2、brew-1.1 和 3)\n默认情况下:

\n
\xe2\x9e\x9c  ~ openssl version\nOpenSSL 1.1.1s  1 Nov 2022\n\xe2\x9e\x9c  ~ which openssl\n/home/linuxbrew/.linuxbrew/bin/openssl\n\n
Run Code Online (Sandbox Code Playgroud)\n

eux*_*xxx 5

是这样解决的:

\n
\xe2\x9e\x9c  ~ CONFIGURE_OPTS="--with-openssl=$(brew --prefix openssl)" pyenv install 3.11.1\n
Run Code Online (Sandbox Code Playgroud)\n

并得到相同的消息,但对于 tkinter lib。安装此由

\n
\xe2\x9e\x9c  ~ brew install tcl-tk\n
Run Code Online (Sandbox Code Playgroud)\n

一切都很好:

\n
\xe2\x9e\x9c  ~ CONFIGURE_OPTS="--with-openssl=$(brew --prefix openssl)" pyenv install 3.11.1\nDownloading Python-3.11.1.tar.xz...\n-> https://www.python.org/ftp/python/3.11.1/Python-3.11.1.tar.xz\nInstalling Python-3.11.1...\nInstalled Python-3.11.1 to /home/eustignos/.pyenv/versions/3.11.1\n
Run Code Online (Sandbox Code Playgroud)\n