简体   繁体   中英

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. There are many guides that describe how to run scripts in the Rosetta Terminal. But can you somehow combine this Feature with Visual Studio Codes Jupyter extension? I can successfully use PyQt5 in the Rosetta terminal, but when I run Jupiter Notebooks (*.ipynb files), the code will return an Error:

---------------------------------------------------------------------------
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.

So is there any way to tell VSCode to run these Notebooks with Rosetta? Or is there another workaround I'm currently not thinking of?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM