Skip to content

Instantly share code, notes, and snippets.

@japsu
Last active February 9, 2022 21:34
Show Gist options
  • Save japsu/6064e85c33c0ff2e7ad8 to your computer and use it in GitHub Desktop.
Save japsu/6064e85c33c0ff2e7ad8 to your computer and use it in GitHub Desktop.
ARCHIVED: How to get NumPy and SciPy working in a virtualenv under Mac OS X

ARCHIVED: How to get NumPy and SciPy working in a virtualenv under Mac OS X

Please don't use this method any more, this is ages old (2014, Python 2.7).

Assuming you use virtualenv for Python library hygiene. Now you want Numpy and Scipy in your project.

NumPy and SciPy can not be easily installed under Mac OS X with a simple

pip install scipy

due to heavy dependencies.

However, homebrew-python provides them as recipes. Therefore you can

  1. install numpy and scipy from homebrew-python
  2. symlink them into a virtualenv

Try it:

brew install homebrew/python/scipy
python -m virtualenv venv-playground
ln -s /usr/local/lib/python2.7/site-packages/{numpy,scipy}* venv-playground/lib/python2.7/site-packages/
source venv-playground/bin/activate
pip freeze

You should see something like this:

numpy==1.9.0
scipy==0.14.0
wsgiref==0.1.2
@mmaclow
Copy link

mmaclow commented Feb 9, 2022

So I installed scipy using MacPorts, and linked it to lib/python3.10/site-packages, which is where the virtualenv installed by MacPorts installs packages (I installed numpy using pip to test). Then I activated the virtual environment and did pip freeze. It only shows numpy==1.22.2 but not scipy. Is there an additional step needed to let pip know that scipy is available? It keeps trying to rebuild it when installing other packages!

@japsu
Copy link
Author

japsu commented Feb 9, 2022

Sorry, this gist is ages old and I don't recommend this method any more.

@mmaclow
Copy link

mmaclow commented Feb 9, 2022

Probably why it doesn't work! Oh well.

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