Python 2和Pyenv:在MacOS上使用共享库构建

发布于 2025-01-22 05:16:56 字数 2188 浏览 2 评论 0原文

我正在尝试使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

森林迷了鹿 2025-01-29 05:16:56

这就是我修复它的方式:

  1. 重新安装命令行工具:
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
  1. 运行macOS更新以更新命令行工具。

  2. 重新启动计算机。 (不确定这是否与此有关,但没有伤害)。

  3. 与Pyenv安装Python 2:

export PYTHON_CONFIGURE_OPTS="--enable-shared" && pyenv install 2.7.18

This is how I got it fixed:

  1. Re-install command line tools:
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
  1. Run macOS updates to update the command line tools.

  2. Restart the computer. (Not sure if this had anything to do with it, but it didn't hurt).

  3. Install Python 2 with pyenv:

export PYTHON_CONFIGURE_OPTS="--enable-shared" && pyenv install 2.7.18
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文