为什么我的pyenv无法安装任何版本的Python?

问题描述 投票:0回答:1

我有一台 Macbook M3 Pro,并从旧版 Intel Pro 转移了我的所有内容。我已经安装了 pyenv,但是当我尝试安装任何版本的 Python 时,都会出现构建错误。这是一个例子:

python-build: use openssl@3 from homebrew
python-build: use readline from homebrew
Downloading Python-3.11.9.tar.xz...
-> https://www.python.org/ftp/python/3.11.9/Python-3.11.9.tar.xz
Installing Python-3.11.9...
python-build: use tcl-tk from homebrew
python-build: use readline from homebrew
python-build: use ncurses from homebrew
python-build: use zlib from xcode sdk
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/ashtonsperry/.pyenv/versions/3.11.9/lib/python3.11/curses/__init__.py", line 13, in <module>
    from _curses import *
ModuleNotFoundError: No module named '_curses'
WARNING: The Python curses extension was not compiled. Missing the ncurses lib?
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'readline'
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/ashtonsperry/.pyenv/versions/3.11.9/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 (OS X 14.5 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/p3/7nvxx8mx4x19125mj6fnjj0h0000gn/T/python-build.20240708161245.10785
Results logged to /var/folders/p3/7nvxx8mx4x19125mj6fnjj0h0000gn/T/python-build.20240708161245.10785.log

Last 10 log lines:
        DYLD_LIBRARY_PATH=/var/folders/p3/7nvxx8mx4x19125mj6fnjj0h0000gn/T/python-build.20240708161245.10785/Python-3.11.9 ./python.exe -E -m ensurepip \
            $ensurepip --root=/ ; \
    fi
Looking in links: /var/folders/p3/7nvxx8mx4x19125mj6fnjj0h0000gn/T/tmp8_w0_bq0
Processing /var/folders/p3/7nvxx8mx4x19125mj6fnjj0h0000gn/T/tmp8_w0_bq0/setuptools-65.5.0-py3-none-any.whl
Processing /var/folders/p3/7nvxx8mx4x19125mj6fnjj0h0000gn/T/tmp8_w0_bq0/pip-24.0-py3-none-any.whl
Installing collected packages: setuptools, pip
  WARNING: The scripts pip3 and pip3.11 are installed in '/Users/ashtonsperry/.pyenv/versions/3.11.9/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-24.0 setuptools-65.5.0

我知道这与Apple的新M芯片有关,而且我确实知道我的Brew在x86上运行,而我的系统是arm64。但我不知道该怎么做才能解决这个问题。我尝试过 Python 3.9.x、3.10.x 和 3.11.x,但没有成功。这一切都始于我的张量流杀死了我的 Jupyter 笔记本上的内核。

python tensorflow arm homebrew pyenv
1个回答
0
投票

安装完pyenv后,你的shell环境配置了吗?如果您还没有这样做,请这样做。要配置 shell,请参阅安装指南:https://github.com/pyenv/pyenv?tab=readme-ov-file#installation。你还安装了xcode命令行工具吗?你需要工具。

然后,您可能需要在安装您首选的 python 版本之前安装构建依赖项。使用此脚本:brew install openssl readline sqlite3 xz zlib tcl-tk。请参阅 https://github.com/pyenv/pyenv/wiki#suggested-build-environment

您还需要安装 ncurses,这是运行 macOS 14+ 的 Apple Silicon 机器所必需的。

“在某些机器上安装 >=3.12.1 的 Python 版本可能需要 ncurses,但似乎缺少 ncurses。使用以下命令安装:brew install ncurses”(请参阅 https://github.com/pyenv/pyenv/wiki/Common -构建问题)。

© www.soinside.com 2019 - 2024. All rights reserved.