简体   繁体   English

如何使用 Rosetta 在 M1 Mac 上的 Visual Studio Code 中运行 Jupyter Notebooks

[英]How can I run Jupyter Notebooks in Visual Studio Code on M1 Mac with Rosetta

Using PyQt5 on the M1 Mac is not a Problem.在 M1 Mac 上使用 PyQt5 不是问题。 There are many guides that describe how to run scripts in the Rosetta Terminal.有许多指南描述了如何在 Rosetta 终端中运行脚本。 But can you somehow combine this Feature with Visual Studio Codes Jupyter extension?但是你能以某种方式将此功能与 Visual Studio Codes Jupyter 扩展结合起来吗? I can successfully use PyQt5 in the Rosetta terminal, but when I run Jupiter Notebooks (*.ipynb files), the code will return an Error:我可以在 Rosetta 终端中成功使用 PyQt5,但是当我运行 Jupiter Notebooks(*.ipynb 文件)时,代码将返回错误:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last) /var/folders/bh/k5kj66jn2cdby4ln1b3hgmvh0000gn/T/ipykernel_73131/2609138369.py in <module>
    ----> 1 from PyQt5.QtWidgets import QApplication, QLabel
          2 app = QApplication([])
          3 label = QLabel('test')
          4 label.show()
    
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PyQt5/QtWidgets.abi3.so, 2): no suitable image found.  Did find:    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PyQt5/QtWidgets.abi3.so: mach-o, but wrong architecture     /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PyQt5/QtWidgets.abi3.so: mach-o, but wrong architecture

This happens, because installing PyQt5 via the Rosetta terminal doesn't use the arm64 architecture, which the computer is based on, but the Rosetta i386 architecture.出现这种情况是因为通过 Rosetta 终端安装 PyQt5 并没有使用计算机所基于的 arm64 架构,而是使用 Rosetta i386 架构。

So is there any way to tell VSCode to run these Notebooks with Rosetta?那么有什么方法可以告诉 VSCode 用 Rosetta 来运行这些 Notebooks 吗? Or is there another workaround I'm currently not thinking of?还是我目前没有想到的另一种解决方法?

请在使用rosetta 打开的终端中创建一个虚拟环境,并在VSCode 中将jupyter notebook 的内核设置为新环境。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Jupyter Notebooks 中的错误,但在 Mac 终端或 Visual Studio Code 中没有 - error in Jupyter Notebooks but not in Mac Terminal or Visual Studio Code 尝试在 mac m1 上的 jupyter 笔记本中运行“从 tensorflow.keras.utils import to_categorical” - Trying to run "from tensorflow.keras.utils import to_categorical" in jupyter notebooks on mac m1 M1 Mac Tensorflow VS Code Rosetta2 - M1 Mac Tensorflow VS Code Rosetta2 如何检查 Python 是否在 M1 mac 上运行,甚至在 Rosetta 下? - How to check if Python is running on an M1 mac, even under Rosetta? 如何在带有 M1 芯片的 Mac 上运行 Kivy - How can I run Kivy on my Mac with M1 chip 无法运行 jupyter (Mac M1 Max) - Cannot run jupyter (Mac M1 Max) 如何在 Visual Studio Code 中禁用 Jupyter 笔记本的 Enter 键自动完成 - How to disable Enter key autocomplete for Jupyter notebooks in Visual Studio Code 如何在 Visual Studio Code 中更改 Anaconda/Jupyter Notebooks 使用的端口 - How to Change Port used by Anaconda/Jupyter Notebooks in Visual Studio Code Visual Studio Code:调试 Jupyter Notebook 不起作用 - Visual Studio Code: Debugging of Jupyter Notebooks not working 如何在 M1 mac 上使用 pandas? (没有rosetta或以任何其他方式更改为x86环境) - How to use pandas on M1 mac? (without rosetta or changing to x86 environment in any other way)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM