#配置当前shell的python版本,退出shell则失效
pyenv shell 3.7.17
#配置所在项目(目录)的python版本
pyenv local 3.7.17
#配置当前用户的系统使用的python版本
pyenv global 3.7.17
#查看当前版本
python -V
install python develop
Bash
1
2
3
4
5
6
7
8
9
10
exportARCHFLAGS="-arch arm64"; pyenv install 3.8-dev
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Cloning https://github.com/python/cpython...
Installing Python-3.8-dev...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.8-dev to /usr/local/var/pyenv/versions/3.8-dev
cd /usr/local/var/pyenv/versions/3.8-dev
查看安装报错详情
代码
1
pyenv install 3.9.15 --verbose
安装失败
报错提示缺少lib,搜索关键字ModuleNotFoundError: No module named '_lzma' WARNING: The Python lzma extension was not compiled. Missing the lzma lib
admin@admins-MacBook-Pro~%exportARCHFLAGS="-arch arm64";arch--arm64pyenvinstall3.7.15pyenv:/Users/example/.pyenv/versions/3.7.15alreadyexistscontinuewithinstallation?(y/N)ypython-build:useopensslfromhomebrewpython-build:usereadlinefromhomebrewDownloadingPython-3.7.15.tar.xz...->https://www.python.org/ftp/python/3.7.15/Python-3.7.15.tar.xz
InstallingPython-3.7.15...patchingfile'Doc/library/ctypes.rst'patchingfile'Lib/test/test_unicode.py'patchingfile'Modules/_ctypes/_ctypes.c'patchingfile'Modules/_ctypes/callproc.c'patchingfile'Modules/_ctypes/ctypes.h'patchingfilesetup.pypatchingfile'Misc/NEWS.d/next/Core and Builtins/2020-06-30-04-44-29.bpo-41100.PJwA6F.rst'patchingfile'Modules/_decimal/libmpdec/mpdecimal.h'patchingfilesetup.pypython-build:usereadlinefromhomebrewpython-build:usezlibfromxcodesdkTraceback(mostrecentcalllast):File"<string>",line1,in<module>File"/Users/example/.pyenv/versions/3.7.15/lib/python3.7/lzma.py",line27,in<module>from_lzmaimport*ModuleNotFoundError:Nomodulenamed'_lzma'WARNING:ThePythonlzmaextensionwasnotcompiled.Missingthelzmalib?InstalledPython-3.7.15to/Users/example/.pyenv/versions/3.7.15
prefer_openssl11
exportPYTHON_BUILD_CONFIGURE_WITH_OPENSSL=1# Avoid a compilation error when linking against OpenSSL built with SSLv3 support (fixed in 3.10.0) (#2181)exportPYTHON_CFLAGS="-DOPENSSL_NO_SSL3${PYTHON_CFLAGS:+ $PYTHON_CFLAGS}"install_package "openssl-1.1.1u""https://www.openssl.org/source/openssl-1.1.1u.tar.gz#e2f8d84b523eecd06c7be7626830370300fbcc15386bf5142d72758f6963ebc6" mac_openssl --if has_broken_mac_openssl
install_package "readline-8.1""https://ftpmirror.gnu.org/readline/readline-8.1.tar.gz#f8ceb4ee131e3232226a17f51b164afc46cd0b9e6cef344be87c65962cb82b02" mac_readline --if has_broken_mac_readline
if has_tar_xz_support;then install_package "Python-3.9.17""https://www.python.org/ftp/python/3.9.17/Python-3.9.17.tar.xz#30ce057c44f283f8ed93606ccbdb8d51dd526bdc4c62cce5e0dc217bfa3e8cee" standard verify_py39 copy_python_gdb ensurepip
else install_package "Python-3.9.17""https://www.python.org/ftp/python/3.9.17/Python-3.9.17.tgz#8ead58f669f7e19d777c3556b62fae29a81d7f06a7122ff9bc57f7dd82d7e014" standard verify_py39 copy_python_gdb ensurepip
fi