Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[macOS] Does not find or have arm64 build #2098

Open
flekschas opened this issue Apr 13, 2022 · 1 comment
Open

[macOS] Does not find or have arm64 build #2098

flekschas opened this issue Apr 13, 2022 · 1 comment

Comments

@flekschas
Copy link

Summary

  • OS: macOS
  • Architecture: Apple M1, ARM 64Bit
  • Psutil version: 5.9.0
  • Python version: 3.9.10 or 3.10.4
  • Type: installation

Description

When trying to install the following conda environment (see at the end) with miniforge and trying to import psutil I get the following error

environment.yml:

name: jscatter

channels:
  - conda-forge
  - defaults

dependencies:
  - python>=3.7
  - nodejs==16.6.*
  - matplotlib
  - numpy
  - pandas
  - pyarrow
  - pip
  - pip:
    - jupyterlab>=3.0.6
    - ipywidgets>=7.6.3
    - jupyterlab_widgets>=1.0.0

Error:

Python 3.10.4 | packaged by conda-forge | (main, Mar 24 2022, 17:42:03) [Clang 12.0.1 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/Fritz/miniforge3/envs/jscatter/lib/python3.10/site-packages/psutil/__init__.py", line 123, in <module>
    from . import _psosx as _psplatform
  File "/Users/Fritz/miniforge3/envs/jscatter/lib/python3.10/site-packages/psutil/_psosx.py", line 14, in <module>
    from . import _psutil_osx as cext
ImportError: dlopen(/Users/Fritz/miniforge3/envs/jscatter/lib/python3.10/site-packages/psutil/_psutil_osx.cpython-310-darwin.so, 0x0002): tried: '/usr/local/mysql/lib//_psutil_osx.cpython-310-darwin.so' (no such file), '/Users/Fritz/miniforge3/envs/jscatter/lib/python3.10/site-packages/psutil/_psutil_osx.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/_psutil_osx.cpython-310-darwin.so' (no such file), '/usr/lib/_psutil_osx.cpython-310-darwin.so' (no such file)

Having read #2016, I wonder if the issue is a clash with the installed Python build, which is arm64 and not arm64e

file $(which python)
/Users/Fritz/miniforge3/envs/jscatter/bin/python: Mach-O 64-bit executable arm64

Any ideas what might cause the issue?

What's odd is that when I reinstall psutil manually it looks like it's grabbing the right build

(jscatter) Fritz pip uninstall psutil
Found existing installation: psutil 5.9.0
Uninstalling psutil-5.9.0:
  Would remove:
    /Users/Fritz/miniforge3/envs/jscatter/lib/python3.10/site-packages/psutil-5.9.0.dist-info/*
    /Users/Fritz/miniforge3/envs/jscatter/lib/python3.10/site-packages/psutil/*
Proceed (Y/n)? Y
  Successfully uninstalled psutil-5.9.0
(jscatter) Fritz pip install psutil --no-cache-dir
Collecting psutil
  Downloading psutil-5.9.0.tar.gz (478 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 478.3/478.3 KB 2.4 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: psutil
  Building wheel for psutil (setup.py) ... done
  Created wheel for psutil: filename=psutil-5.9.0-cp310-cp310-macosx_11_0_arm64.whl size=214440 sha256=38fd1f45be58b03a1659e8f94ecbe11e79cf8d2945afd144b2830afdb971307c
  Stored in directory: /private/var/folders/1q/43l11bl1573fx_sb848qnwmr0000gp/T/pip-ephem-wheel-cache-ywng_buj/wheels/0b/90/2e/be670c56c3ad980428e845d7f66480dcdfa008c3af2f27a2bf
Successfully built psutil
Installing collected packages: psutil
Successfully installed psutil-5.9.0
@flekschas flekschas added the bug label Apr 13, 2022
@github-actions github-actions bot added the macos label Apr 13, 2022
@flekschas flekschas changed the title [macOS] Does not find or have arm build [macOS] Does not find or have arm64 build Apr 13, 2022
@jasonzjc
Copy link

Have you checked the arch when psutil is built?

I had the exact same issue. When I was checking the arch, it appeared to be i386.

$ arch
i386

I haven't figured out why, Probably because the pyenv is working. In this case, psutil was built for x86_64. Maybe your miniconda also simulated i386 architecture?

How I get it work.
When I opened a different terminal, and recheck it, it is now arm64. Haven't figured out why.

$ arch
arm64

After I uninstalled psuntil and rebuilt it, and it works. Meanwhile, ipykernel also works, solving the same problem you have here.

$ python
Python 3.9.4 (default, Feb  3 2022, 15:22:53) 
[Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/JZhao/.pyenv/versions/3.9.4/lib/python3.9/site-packages/psutil/__init__.py", line 123, in <module>
    from . import _psosx as _psplatform
  File "/Users/JZhao/.pyenv/versions/3.9.4/lib/python3.9/site-packages/psutil/_psosx.py", line 14, in <module>
    from . import _psutil_osx as cext
ImportError: dlopen(/Users/JZhao/.pyenv/versions/3.9.4/lib/python3.9/site-packages/psutil/_psutil_osx.cpython-39-darwin.so, 0x0002): tried: '/Users/JZhao/.pyenv/versions/3.9.4/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)
>>> exit()
$ pip uninstall psutil
Found existing installation: psutil 5.9.0
Uninstalling psutil-5.9.0:
  Would remove:
    /Users/JZhao/.pyenv/versions/3.9.4/lib/python3.9/site-packages/psutil-5.9.0-py3.9.egg-info
    /Users/JZhao/.pyenv/versions/3.9.4/lib/python3.9/site-packages/psutil/*
Proceed (Y/n)? y
  Successfully uninstalled psutil-5.9.0
$ arch                
arm64
$ pip install --no-binary :all: psutil
Collecting psutil
  Downloading psutil-5.9.1.tar.gz (479 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 479.1/479.1 kB 657.1 kB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: psutil
  Building wheel for psutil (pyproject.toml) ... done
  Created wheel for psutil: filename=psutil-5.9.1-cp39-cp39-macosx_12_0_arm64.whl size=239073 sha256=4a5151d2a274c3711e7c462ff11a82b022cfa063436d137e36f1dacffd8a1c7c
  Stored in directory: /Users/JZhao/Library/Caches/pip/wheels/65/66/89/7ecefa8b8cfa845352eab83061e5f0f93946a306ae25661e03
Successfully built psutil
Installing collected packages: psutil
Successfully installed psutil-5.9.1
$ python
Python 3.9.4 (default, Feb  3 2022, 15:22:53) 
[Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil
>>> print(psutil.__version__)
5.9.1

It appears that psutil just upgraded to 5.9.1, but it does not appear to relate to this question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants