I am new to python and am trying to run a python 2.7 script. Got pip for python 2.7 and installed a dependency of pyCrypto from the mac terminal shell.
The downloaded python script, I want to try, runs fine in the terminal app when I execute it using python2.
Now I open it in vscode and try to run the script in its terminal and I get
ImportError: dlopen(/Users/xxx/Library/Python/2.7/lib/python/site-packages/Crypto/Cipher/_DES3.so, 2): no suitable image found. Did find:
/Users/xxx/Library/Python/2.7/lib/python/site-packages/Crypto/Cipher/_DES3.so: mach-o, but wrong architecture
/Users/xxx/Library/Python/2.7/lib/python/site-packages/Crypto/Cipher/_DES3.so: mach-o, but wrong architecture
When I run
uname -m
inside a vscode terminal(zsh) on an M1 Mac, I see an output of x86_64
, implying the terminal is running under Rosetta and looking for the intel version of the library.
And when I run uname -m
in the regular mac terminal app, I see arm64
How do I change the terminal inside vscode to use the non rosetta one? Or how do I get the script to run from within vscode?
I'm not familiar with VSCode, but you can manually force the chosen architecture slice of anything you launch with the arch
command (see man arch
).
If you have a script that you'd normally launch like:
./script.py
Then you can force either architecture like so:
arch -x86_64 ./script.py
arch -arm64 ./script.py