Unable to import psutil on M1 mac with miniforge: (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
Question:
I’m using a miniforge environment on an M1 mac, and unable to import psutil:
ImportError: dlopen(/Users/caspsea/miniforge3/lib/python3.9/site-packages/psutil/_psutil_osx.cpython-39-darwin.so, 0x0002): tried: '/Users/caspsea/miniforge3/lib/python3.9/site-packages/psutil/_psutil_osx.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/_psutil_osx.cpython-39-darwin.so' (no such file), '/usr/lib/_psutil_osx.cpython-39-darwin.so' (no such file)
I tried uninstalling and reinstalling using pip but that did not work. I’m using python 3.9, OS Monterey 12.2.1
Answers:
Have you tried:
pip uninstall psutil
followed by:
pip install --no-binary :all: psutil
Thanks Jude’s answer.
I encontered ImportError: dlopen …(mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)) when I run Jupyter Lab from new MacBook.
And when trying intall psutil, I got
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command ‘/usr/bin/clang’ failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for psutil
Failed to build psutil
ERROR: Could not build wheels for psutil, which is required to install pyproject.toml-based projects
to fix that, I download xcode
- https://developer.apple.com/download/all/
- download Command Line Tools for Xcode
and run "pip install –no-binary :all: psutil" again, then problem solved.
I’m using a miniforge environment on an M1 mac, and unable to import psutil:
ImportError: dlopen(/Users/caspsea/miniforge3/lib/python3.9/site-packages/psutil/_psutil_osx.cpython-39-darwin.so, 0x0002): tried: '/Users/caspsea/miniforge3/lib/python3.9/site-packages/psutil/_psutil_osx.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/_psutil_osx.cpython-39-darwin.so' (no such file), '/usr/lib/_psutil_osx.cpython-39-darwin.so' (no such file)
I tried uninstalling and reinstalling using pip but that did not work. I’m using python 3.9, OS Monterey 12.2.1
Have you tried:
pip uninstall psutil
followed by:
pip install --no-binary :all: psutil
Thanks Jude’s answer.
I encontered ImportError: dlopen …(mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)) when I run Jupyter Lab from new MacBook.
And when trying intall psutil, I got
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command ‘/usr/bin/clang’ failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for psutil
Failed to build psutil
ERROR: Could not build wheels for psutil, which is required to install pyproject.toml-based projects
to fix that, I download xcode
- https://developer.apple.com/download/all/
- download Command Line Tools for Xcode
and run "pip install –no-binary :all: psutil" again, then problem solved.