Reputation: 4043
I just upgraded to pycharm 2022.01 and got an error when debugging a python program using m1 mac:
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_cython_wrapper.py", line 8, in <module>
from _pydevd_bundle_ext import pydevd_cython as mod
ModuleNotFoundError: No module named '_pydevd_bundle_ext'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_cython_wrapper.py", line 11, in <module>
from _pydevd_bundle import pydevd_cython as mod
ImportError: cannot import name 'pydevd_cython' from '_pydevd_bundle' (/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydevd_bundle/__init__.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 55, in <module>
from _pydevd_bundle.pydevd_trace_dispatch import (
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_trace_dispatch.py", line 42, in <module>
from _pydevd_bundle.pydevd_cython_wrapper import trace_dispatch as _trace_dispatch, global_cache_skips, global_cache_frame_skips, fix_top_level_trace_and_get_trace_func
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_cython_wrapper.py", line 35, in <module>
mod = getattr(__import__(check_name), mod_name)
ImportError: dlopen(/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_cython_darwin_310_64.cpython-310-darwin.so, 0x0002): tried: '/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_cython_darwin_310_64.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
Process finished with exit code 1
I installed the right version of pycharm. Couldn't find the right .so
version on pypi.
How can I fix this? Is it possible to recompile pydevd for arm64e?
Upvotes: 4
Views: 3855
Reputation: 6466
As a quickfix, you can simply disable cython debugging. This will still enable you to run a debugging session, albeit with less features.
Add this to the environment variables of your run configuration in PyCharm:
PYDEVD_USE_CYTHON=NO
Upvotes: 1
Reputation: 4043
Managed to rebuild pydevd
that comes with PyCharm:
Make sure you have cython
installed to update and compile the cython sources:
sudo pip3 install cython
export PYTHONPATH=/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev:$PYTHONPATH
cd /Applications/PyCharm.app/Contents/plugins/python/helpers/pydev
python3.10 build_tools/build.py
After that, debugging in PyCharm worked fine.
What the rebuild apparently did:
_pydevd_bundle/pydevd_cython_darwin_*.so
files_pydevd_bundle/pydevd_cython.cpython-310-darwin.so
Use the file
command to confirm the binary has the architecture required for new M1 (Apple Silicon) chips:
file _pydevd_bundle/pydevd_cython.cpython-310-darwin.so`
It should output required architecture for M1 like arm64
below:
_pydevd_bundle/pydevd_cython.cpython-310-darwin.so: Mach-O 64-bit bundle arm64
Upvotes: 4