-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
trouble installing on apple silicon M1 #13409
Comments
+1 I am experiencing the same issue. |
+1 the whole point of this new M1 mac is to do ML and scipy is pretty integral.. |
FWIW, I am able to get it to "install" now using the following:
but i get a segmentation fault when doing most things
|
Even with doing this, I'm not able to install scipy, I got an error. end of the error message:
|
Yes we are still trying to figure out how to compile on that architecture. Many people tried alternative ways to do it but got limited success. We'll keep this post up to date when we have more info. Just FYI, the actual error is slightly earlier in the snipped part of the logs |
Workaround building from source: /opt/homebrew/bin/brew install openblas
export OPENBLAS=$(/opt/homebrew/bin/brew --prefix openblas)
export CFLAGS="-falign-functions=8 ${CFLAGS}"
git clone https://github.com/scipy/scipy.git
cd scipy
/opt/homebrew/bin/pip install . |
@lutzroeder numpy.distutils.system_info.NotFoundError: No BLAS/LAPACK libraries found. Note: Accelerate is no longer supported. |
@huwei1024 are you running the arm64 version of brew to install
|
yes, i think so. Homebrew 3.0.0-35-g78f54b0-dirty |
huwei@HuweideMBP-2 scipy % /opt/homebrew/bin/brew --version huwei@HuweideMBP-2 scipy % /usr/local/bin/pip3.9 --version huwei@HuweideMBP-2 scipy % file /usr/local/bin/python3 |
i can confirm @lutzroeder's method was successful on my machine (MBA M1) 🎉. I also no longer get a segmentation fault when doing some things (see my previous comment). (this is all native, not x86_64 emulated under rosetta)
|
still got an error on my M1 MBP... I use a virtual env with tensorflow for mac os. |
Hey,
Also |
@redmlr Did you recently update MacOS? If so, you need to re-install CommandLineTools for each point update. I could get SciPy to install with @lutzroeder's method, but still get the segfault when I import it. |
@lingwhatics Yes you were right, I installed Xcode-CommandLineTools again, but after following the steps, an error occurred while building the wheel.
My command before the error was: |
you can try |
@redmlr i believe conda already provides native-built wheels through mini forge. See this comment on the relevant numpy issue. |
From a maintainer perspective I'd like to express my sympathy for all the difficulties going on in this thread. There are a lot of scipy maintainers that use macOS for their work (including me), and we're very much interested in stability and functionality for the macOS platform. |
@redmlr are you able to install scipy through Edit: @climatebrad corrected me, it is |
Note that it's not the Anaconda-distributed |
Anyone here is using m1 and able to install scipy but when using import statement in the code, it yields error " ModuleNotFoundError: No module named 'scipy' "? Thank you. Please help to import in the code. |
@DavidY0903 that is unrelated to this issue, please open a new one instead. Note that you do need to give many more details about the exact steps you took, how you installed Python, SciPy itself, etc. - this is highly likely to be a simple user error. |
Got it to work on Mac m1. Must use native terminal (not rosetta).
Full details:
|
Did you solve the problem? I am also having this issue when I am trying to import Scipy |
@zhouaad Are you sure thay you are installed After installing |
I guess that's what I'm trying to figure out. When I |
try
|
|
Woof. My advice would be to get up and running with something to manage python environments. If you're on M1, then I'd suggest the Just remember to activate you envs before you install stuff! Also, python 3.10 in my experience isn't hugely supported, so I'd stick to 3.9 for the time being—which again, conda or another env manager makes easy. |
Did you copy Check if you could import scipy in idle started using both commands
|
I was having issues with Wheels so I had to |
There are a few partial solutions above, but it in putting all of them together that I finally got this to work on Python 3.9.13, macOS 12.3 Monterey # Install BLAS and LAPACK
brew info openblas lapack
# FLAGS
export LDFLAGS="-L/opt/homebrew/opt/lapack/lib"
export CPPFLAGS="-I/opt/homebrew/opt/lapack/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/lapack/lib/pkgconfig"
export NPY_DISTUTILS_APPEND_FLAGS=1
export SYSTEM_VERSION_COMPAT=1
export CFLAGS="-falign-functions=8"
# Libraries
export LAPACK=/opt/homebrew/opt/lapack/lib/liblapack.dylib
export BLAS=/opt/homebrew/opt/openblas/lib/libopenblas.dylib
# Install on system or in venv
pip install cython pybind11 pythran
pip install numpy
pip install --no-use-pep517 scipy For reference: ~ % python
Python 3.9.13 (main, May 24 2022, 21:13:51)
[Clang 13.1.6 (clang-1316.0.21.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy
>>> scipy.version.full_version
'1.8.1'
~ % file $(which python)
/opt/homebrew/opt/[email protected]/libexec/bin/python: Mach-O 64-bit executable arm64 |
This continues to get traction for some reason, so let me just say that none of these workarounds or using env vars are needed anymore. The contributor docs are up to date: http://scipy.github.io/devdocs/dev/dev_quickstart.html, and it's literally 2-3 commands to build/install on macOS M1, and there are no known issues. |
@rgommers I followed the document you linked and it was not enough to get my environment working. @nicolasgrasset's post finally resolved my issues and I was able to get it building on my machine. |
@aiell0 can you please open a new issue with what you are seeing when following that link, and Cc me? All known problems are fixed, so if you see a new problem it needs fixing. Maybe something is still screwed up specifically in Homebrew or some such thing. |
Got scipy to install using a variant of @nicolasgrasset solution. Unfortunately, @rgommers your document didn't solve my issue. However, exporting these paths did. OSX 11.1. Python 3.9.5. M1 native. Scipy 1.9.0. Install openblas
Install additional dependencies
Get paths that are required to be set in environment
Execute the above three export statements in your terminal
Original error
|
The only one you need is PKG_CONFIG_PATH, by the way. "For pkg-config to find openblas you may need to set:" -- and Meson / SciPy uses pkg-config here. |
@eli-schwartz Ah yes, that makes sense. |
REF: https://stackoverflow.com/a/69710042/3307521: |
This absolutely solved the issue! Thanks |
None of these solutions are currently working on my M1 running Python 3.11 :(. |
There are wheels on PyPI, so a regular
This is not a useful bug report. You are trying to build from source (because there are no 3.11 packages just yet - they will arrive soon). Building from source does work fine, but you are probably missing a dependency. Please open a new bug report with exactly what you did and the build log showing the error you are seeing (feel free to Cc me). |
This issue has stopped being useful, it's just a grab bag of comments for wheels and conda packages, plus building from source in various configs. I will lock this issue here. If you do have a new problem not solved by the docs for building from source, please open a new and complete issue so we can help you. And as always, please use binaries unless you really do need to build from source! |
EDIT: As of 2021-08-06, this solution seems to work for scipy 1.7.0 (native, not through rosetta):
Thanks goes to @lutzroder for the figuring out this solution
Hi there, I did not find any other issues related to this on here. I'm having some issues installing scipy on my M1 Macbook Air.
2020 Macbook Air M1
Mac OS Big Sur 11.0.1
Reproducing code example:
Install python3.9.1 on Mac OS through brew (natively, not x86):
Install numpy (solution from this numpy issue):
Install pandas and matplotlib
Try to install scipy:
Error message:
Error output (after successfully installing numpy, pandas, matplotlib):
Scipy/Numpy/Python version information:
The text was updated successfully, but these errors were encountered: