1

Installing numpy and scipy from source like this (say, in a fresh Python 2.7 pyenv virtualenv):

pip install numpy==1.14.6 scipy==1.0.1 --no-binary numpy,scipy

gets their installers to use a ~/.numpy-site.cfg file that points to my openblas installation.

This used to work. Now it produces a long stack trace ending with:

      File "/usr/local/var/pyenv/versions/2.7.16/envs/issue/lib/python2.7/site-packages/setuptools/sandbox.py", line 45, in _execfile
        exec(code, globals, locals)
      File "/var/folders/_b/q30qg_l50b5gvqd8y4_wb9h00000gn/T/easy_install-o9MJ5E/numpy-1.17.1/setup.py", line 31, in <module>
        if sys.version_info[0] < 3:
    RuntimeError: Python version >= 3.5 required.
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Q. What changed?
Q. Why does it say Python version >= 3.5 required. in a Python 2.7 installation?
Q. How to fix it?

2 Answers 2

3

The scipy 1.0.1 installer requires numpy as a prerequisite, but the multiple installers working together end up getting the latest version of numpy unless numpy is already present.

What changed: The latest version of numpy requires Python 3.5+, hence the error message.

So even though the pip command explicitly asked to install numpy==1.14.6 scipy==1.0.1, it triggers a newer numpy installer that fails on Python 2. (The last entry in the stack trace shows numpy-1.17.1 requiring Python 3.)

The problem arises in the interaction between pip, the scipy and numpy installers, and easy_install. Details in pip issue #6945.

Workaround: Install numpy first. Then install scipy. Alternatively, the one-line install might work if you don't need the --no-binary option.

Sign up to request clarification or add additional context in comments.

7 Comments

This post made me think that changing the order that numpy and scipy appeared in requirements.txt was sufficient. Only when I tried instally numpy without requirements.txt did I find the real problem with scipy, missing BLAS dev files in my Docker setup.
@cyrf Found this from another project, might also be what you're experiencing: "If you already installed numpy with pip, please note that pip v7+ is caching packages installations, so changing the blas backend after any installation my not work as expected (eg. old backend still in use). Make sure to recompile numpy with the new settings by bypassing the cache with --no-cache-dir"
@cyrf I recommend against using Alpine linux (after wasting a bunch of time on it) because its musl libc gets different math results than glibc! (Also the desired space savings from starting with a smaller Docker base image might not pan out when every image you build adds needed linux packages vs. a larger but shared base image.)
@Jerry101 I would like to buy you a beverage of your choice. Thank you! Your comment helped me avoid a nasty divide by zero exception.
@cyrf you're welcome! Here's a new post that warns about more Alpine pitfalls: Using Alpine can make Python Docker builds 50× slower ... also larger and run slower.
|
0

I also encountered an issue where scipy was been installed through a script and it was trying to install a version 1.7.1 which required python 3.7 at least and i hand 3.6. The workaround was i installed scipy myself and the version i got was 1.5.4.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.