2

I'm trying to install scikit-image on a server that I don't have admin privileges on. Scikit-image requires Cython >= 0.23 as a dependency, but the server has Cython 0.21 installed globally.

$ which Cython
/opt/apps/software/MPI/GCC/4.8.3/OpenMPI/1.8.8/Python/2.7.9/bin/cython

$ cython --version
Cython version 0.21.2

I can install Cython 0.25.2 locally into a .pip folder for my project (following the advice here):

$ pip install Cython -t .pip
$ python ./.pip/cython.py --version
Cython version 0.25.2

I've added ./.pip to the beginning of my PYTHONPATH, but when I try to install scikit-image I get

$ pip install --user scikit-image
...
RuntimeError: Cython >= 0.23 needed to build scikit-image

How can I tell the pip installation to use the version of Cython sitting in my_project/.pip?

5
  • I also get this same problem when I install Cython into my $HOME directory using pip install --user --upgrade Cython Commented Feb 17, 2017 at 20:04
  • Have you tried pip install --user cython? Commented Feb 17, 2017 at 20:28
  • I did, just realized that I needed to add ~/.local/bin to my PATH. I can now run cython --version and get Cython 0.25.2, but the user install of scikit-image still isn't happy and is giving me the same versioning error. Commented Feb 17, 2017 at 20:31
  • so I've done export PYTHONPATH=~/.local/lib/python2.7/site-packages:$PYTHONPATH, but the cluster specific Cython installation shows up first in Python's sys.path. Anyway to make my site-packages show up at the top of sys.path? Commented Feb 17, 2017 at 21:00
  • If you check out the source, add the path as described above, and try python setup.py build_ext --inplace, you see the same error? Commented Feb 17, 2017 at 23:59

1 Answer 1

1

It turned out that the cluster module management system was adding the old version of Cython to Python's sys.path with higher priority than anything I could add to my PYTHONPATH. When I unloaded the Python module I had been using, the default version on the cluster was 2.7.5, which doesn't have pip, so I couldn't install scikit-image as a user while the module was unloaded (additionally, without the module a number of dependencies were missing).

The solution was to use virtualenv, create an environment and install my packages inside that environment. To run my code, I now use /path/to/virtualenv/python my_file.

On the upside, I now know a lot more about the cluster module system and Python paths. Fingers crossed this answer ends up being useful to someone else. An interesting discussion of where Python looks for dependencies is here.

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

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.