question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

failed to install Scipy via `pip` (OSX M1)

See original GitHub issue

System Environment:

macOS Big Sur 11.5.2, M1 processor Python 3.8.11 (using a venv) pip==21.2.4 (updated via pip) setuptools==57.4.0 (updated via pip)

Observed output

(venv) % python -m pip install scipy
Collecting scipy
  Using cached scipy-1.7.1.tar.gz (36.1 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... error
    ERROR: Command errored out with exit status 1:
     command: /Users/work/Repos/endaq-python-calc/venv/bin/python /Users/work/Repos/endaq-python-calc/venv/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py prepare_metadata_for_build_wheel /var/folders/1s/lrjbk2v17m7063f944nmy7vh0000gn/T/tmp7dun4f3u
         cwd: /private/var/folders/1s/lrjbk2v17m7063f944nmy7vh0000gn/T/pip-install-cc3mdfet/scipy_90eec6ff22e54b9d84809dedc230c072
    Complete output (4 lines):
    setup.py:490: UserWarning: Unrecognized setuptools command ('dist_info --egg-base /private/var/folders/1s/lrjbk2v17m7063f944nmy7vh0000gn/T/pip-modern-metadata-0oa55ptb'), proceeding with generating Cython sources and expanding templates
      warnings.warn("Unrecognized setuptools command ('{}'), proceeding with "
    Error: 'None' must be installed before running the build.

    ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/47/33/a24aec22b7be7fdb10ec117a95e1e4099890d8bbc6646902f443fc7719d1/scipy-1.7.1.tar.gz#sha256=6b47d5fa7ea651054362561a28b1ccc8da9368a39514c1bbf6c0977a1c376764 (from https://pypi.org/simple/scipy/) (requires-python:>=3.7,<3.10). Command errored out with exit status 1: /Users/work/Repos/endaq-python-calc/venv/bin/python /Users/work/Repos/endaq-python-calc/venv/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py prepare_metadata_for_build_wheel /var/folders/1s/lrjbk2v17m7063f944nmy7vh0000gn/T/tmp7dun4f3u Check the logs for full command output.

It then tries other versions of scipy, but they all result in the same message.

Any help appreciated, thanks!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
CrepeGoatcommented, Sep 1, 2021

More fixes for anyone else with the same problem (and as a reference for myself, if we’re being honest):

Good to know, thanks! For anyone else reading, I’ll probably be pip installing directly from the git master branch via pip install git+https://github.com/scipy/scipy@master

So this resulted in some errors for me due to, afaik, missing c-library dependencies when compiling from source.

Now I could dig into these C compilation issues. But I’m a Python developer on a time budget, so I’m going to instead opt for the easier solution.

The easier solution

Check your Python interpreter

If you install python through the installer available directly from https://www.python.org/, you’ll install a universal binary. You can tell it’s a universal binary because running in the command line which python3 | xargs file prints to stdout something like the below message, which makes note of both x86_64 and arm64 architectures:

crepegoat@CrepeScape ~ % which python3 | xargs file
/usr/local/bin/python3: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64:Mach-O 64-bit executable arm64]
/usr/local/bin/python3 (for architecture x86_64):	Mach-O 64-bit executable x86_64
/usr/local/bin/python3 (for architecture arm64):	Mach-O 64-bit executable arm64

(If you installed via another means like e.g. Homebrew, as long as the above command prints the same result this will still work.)

Set zsh to run programs in x86_64 mode

By default, Terminal (i.e., zsh) will run programs in arm64 mode; this is evidenced by the result of running uname -m:

crepegoat@CrepeScape ~ % uname -m
arm64

This can be changed on either a command-, terminal-session- or permanent-basis using the arch command. Below I opt for the session-basis change:

crepegoat@CrepeScape ~ % arch -x86_64 zsh
crepegoat@CrepeScape ~ % uname -m                          
x86_64

Install scipy as usual

Now after setting up zsh in x86_64 mode, running pip will install binaries for the x86_64 architecture, with which scipy has perfectly functional compatibility. At the time of writing this, I’ve successfully installed scipy==1.7.1 on my system with this method. If you’re reading this, I hope it helps you too 😃

2reactions
GT135813commented, Aug 30, 2021

@CrepeGoat No worries at all. Best of luck.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to install SciPy on Apple Silicon (ARM / M1)
This solution worked on my M1 machine with pyenv : brew install openblas OPENBLAS="$(brew --prefix openblas)" pip install numpy scipy.
Read more >
Install Python with NumPy SciPy Matplotlib on macOS Big Sur ...
I will show you how to install natively the above three libraries, using arm64 Apple Silicon versions. I assume that you have one...
Read more >
Apple silicon M1 for the many-body physicist | by Alex Schuckert
I have an M1 Pro with 10 cores. Now you need to make sure that whatever package you install does not install numpy...
Read more >
How to Install Scipy in Python on MacOS? - GeeksforGeeks
Follow the below steps to install the Scipy package on macOS using pip: Step 1: Install the latest Python3 in MacOS.
Read more >
Install Python with NumPy SciPy Matplotlib on ... - YouTube
How to install Python with NumPy, SciPy, Matplotlib on macOS Big Sur Apple Silicon M1.The procedure presented in the video should work on ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found