Python 2和Pyenv:在MacOS上使用共享库构建
我正在尝试使用Pyenv安装Python 2,并在MacOS 12.3.1上使用命令安装python 2:
export PYTHON_CONFIGURE_OPTS="--enable-shared" && pyenv install 2.7.18
但是我得到了错误:
python-build: use [email protected] from homebrew
python-build: use readline from homebrew
Installing Python-2.7.18...
patching file configure
patching file configure.ac
patching file setup.py
patching file Mac/Tools/pythonw.c
patching file setup.py
patching file Doc/library/ctypes.rst
patching file Lib/test/test_str.py
patching file Lib/test/test_unicode.py
patching file Modules/_ctypes/_ctypes.c
patching file Modules/_ctypes/callproc.c
patching file Modules/_ctypes/ctypes.h
patching file Modules/_ctypes/callproc.c
patching file setup.py
patching file Mac/Modules/qt/setup.py
patching file setup.py
python-build: use tcl-tk from homebrew
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
BUILD FAILED (OS X 12.3.1 using python-build 20180424)
Inspect or clean up the working tree at /var/folders/6f/08_5byqn69q2bpqx5x7vs1000000gn/T/python-build.20220418170004.43219
Results logged to /var/folders/6f/08_5byqn69q2bpqx5x7vs1000000gn/T/python-build.20220418170004.43219.log
Last 10 log lines:
echo "generate-posix-vars failed" ; \
rm -f ./pybuilddir.txt ; \
exit 1 ; \
fi
dyld[51418]: Library not loaded: /System/Library/Frameworks/Python.framework/Versions/2.7/Python
Referenced from: /private/var/folders/6f/08_5byqn69q2bpqx5x7vs1000000gn/T/python-build.20220418170004.43219/Python-2.7.18/python.exe
Reason: tried: '/System/Library/Frameworks/Python.framework/Versions/2.7/Python' (no such file), '/Library/Frameworks/Python.framework/Versions/2.7/Python' (no such file)
/bin/sh: line 1: 51418 Abort trap: 6 DYLD_LIBRARY_PATH=/var/folders/6f/08_5byqn69q2bpqx5x7vs1000000gn/T/python-build.20220418170004.43219/Python-2.7.18 ./python.exe -E -S -m sysconfig --generate-posix-vars
generate-posix-vars failed
make: *** [pybuilddir.txt] Error 1
似乎正在尝试引用不再存在的系统的Python 2。
有什么想法吗?
谢谢
I'm trying to install Python 2 with pyenv and shared libraries on macOS 12.3.1 with the command:
export PYTHON_CONFIGURE_OPTS="--enable-shared" && pyenv install 2.7.18
But I get the error:
python-build: use [email protected] from homebrew
python-build: use readline from homebrew
Installing Python-2.7.18...
patching file configure
patching file configure.ac
patching file setup.py
patching file Mac/Tools/pythonw.c
patching file setup.py
patching file Doc/library/ctypes.rst
patching file Lib/test/test_str.py
patching file Lib/test/test_unicode.py
patching file Modules/_ctypes/_ctypes.c
patching file Modules/_ctypes/callproc.c
patching file Modules/_ctypes/ctypes.h
patching file Modules/_ctypes/callproc.c
patching file setup.py
patching file Mac/Modules/qt/setup.py
patching file setup.py
python-build: use tcl-tk from homebrew
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
BUILD FAILED (OS X 12.3.1 using python-build 20180424)
Inspect or clean up the working tree at /var/folders/6f/08_5byqn69q2bpqx5x7vs1000000gn/T/python-build.20220418170004.43219
Results logged to /var/folders/6f/08_5byqn69q2bpqx5x7vs1000000gn/T/python-build.20220418170004.43219.log
Last 10 log lines:
echo "generate-posix-vars failed" ; \
rm -f ./pybuilddir.txt ; \
exit 1 ; \
fi
dyld[51418]: Library not loaded: /System/Library/Frameworks/Python.framework/Versions/2.7/Python
Referenced from: /private/var/folders/6f/08_5byqn69q2bpqx5x7vs1000000gn/T/python-build.20220418170004.43219/Python-2.7.18/python.exe
Reason: tried: '/System/Library/Frameworks/Python.framework/Versions/2.7/Python' (no such file), '/Library/Frameworks/Python.framework/Versions/2.7/Python' (no such file)
/bin/sh: line 1: 51418 Abort trap: 6 DYLD_LIBRARY_PATH=/var/folders/6f/08_5byqn69q2bpqx5x7vs1000000gn/T/python-build.20220418170004.43219/Python-2.7.18 ./python.exe -E -S -m sysconfig --generate-posix-vars
generate-posix-vars failed
make: *** [pybuilddir.txt] Error 1
It seems that is trying to reference the system's Python 2 which doesn't exist anymore.
Any ideas?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是我修复它的方式:
运行macOS更新以更新命令行工具。
重新启动计算机。 (不确定这是否与此有关,但没有伤害)。
与Pyenv安装Python 2:
This is how I got it fixed:
Run macOS updates to update the command line tools.
Restart the computer. (Not sure if this had anything to do with it, but it didn't hurt).
Install Python 2 with pyenv: