[英]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.