刚刚在我的 Mac m1 上重新安装了 Anaconda,现在当我尝试使用命令行打开 Jupyter Notebook 时,出现以下错误:
jupyter notebook
Traceback (most recent call last):
File "/Users/alborzgharabaghi/opt/anaconda3/bin/jupyter-notebook", line 7, in <module>
from notebook.notebookapp import main
File "/Users/alborzgharabaghi/opt/anaconda3/lib/python3.8/site-packages/notebook/notebookapp.py", line 49, in <module>
from zmq.eventloop import ioloop
File "/Users/alborzgharabaghi/.local/lib/python3.8/site-packages/zmq/__init__.py", line 57, in <module>
_load_libzmq()
File "/Users/alborzgharabaghi/.local/lib/python3.8/site-packages/zmq/__init__.py", line 32, in _load_libzmq
from . import libzmq
ImportError: dlopen(/Users/alborzgharabaghi/.local/lib/python3.8/site-packages/zmq/libzmq.cpython-38-darwin.so, 10): no suitable image found. Did find:
/Users/alborzgharabaghi/.local/lib/python3.8/site-packages/zmq/libzmq.cpython-38-darwin.so: mach-o, but wrong architecture
/Users/alborzgharabaghi/.local/lib/python3.8/site-packages/zmq/libzmq.cpython-38-darwin.so: mach-o, but wrong architecture
如有任何帮助,我们将不胜感激。
我在 M1 上使用此 CLI 命令和其他 CLI 命令时也遇到过类似的问题。 MacOS 附带旧版本的 Bash,将 Bash 更新到 v5(并确保我在该环境中运行命令)为我清除了这个错误。本文帮助:在 MacOS 上升级 Bash
在我尝试在配备 M2 的 MacBook Pro 上的 Python 3.7.13 虚拟环境中安装笔记本时遇到类似的问题,我确定根本原因是 pyzmq。挑战源于这样一个事实:根据安装维基,MacOS Arm 架构的轮子是专门为大于或等于 3.9 的 Python 版本构建的。 pyzmq安装过程中出现的具体错误信息:
ERROR: Could not build wheels for pyzmq, which is required to install pyproject.toml-based projects.
为了解决这个问题,我参考了网上博客,最初通过使用 Homebrew 安装 Python 构建依赖项解决了问题:
brew install openssl readline sqlite3 xz zlib libffi cython zeromq
随后,我激活了 Python 3.7 虚拟环境并从源代码安装了 pyzmq:
pip install --no-binary pyzmq pyzmq
成功完成这些步骤后,我就可以无缝安装 Jupyter 笔记本包了:
pip install notebook