user3268288
user3268288

Reputation: 11

Cannot import numpy

I built numpy locally from source with python 2.7.2 because I dont have root access to the system. After installation, I appended the following path /path/to/install/lib/python2.7/site-packages to PYTHONPATH. When I tried to import from python, I get following error:

import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/path/to/numpy/numpy-1.8.0/lib/python2.7/site-packages/numpy/__init__.py", line 153, in <module>
    from . import add_newdocs
  File "/path/to/numpy/numpy-1.8.0/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "/path/to/numpy/numpy-1.8.0/lib/python2.7/site-packages/numpy/lib/__init__.py", line 18, in <module>
    from .polynomial import *
  File "/path/to/numpy/numpy-1.8.0/lib/python2.7/site-packages/numpy/lib/polynomial.py", line 19, in <module>
    from numpy.linalg import eigvals, lstsq, inv
  File "/path/to/numpy/numpy-1.8.0/lib/python2.7/site-packages/numpy/linalg/__init__.py", line 50, in <module>
    from .linalg import *
  File "/path/to/numpy/numpy-1.8.0/lib/python2.7/site-packages/numpy/linalg/linalg.py", line 29, in <module>
    from numpy.linalg import lapack_lite, _umath_linalg
ImportError: libgfortran.so.1: cannot open shared object file: No such file or directory

I also made GCC locally and have all the paths and library paths set correctly. While building numpy, I didn't build ATLAS because the machine I am running on has cpu throttling on and I cannot change it. Without turning throttling off, ATLAS cannot be installed.

What could be the possible reasons for this error ?

Upvotes: 0

Views: 6304

Answers (1)

Andrew Walker
Andrew Walker

Reputation: 42440

This looks like a dependancy issue with the fortran libraries on your machine.

In general, local installation of any package can be achieved in three (easy) ways that I know of, none of which require changing the python path.

  1. virtualenv
  2. conda
  3. pip

The easiest of these is using pip with the --user flag.

pip install numpy --user

Make sure ~/.local/bin is in the $PATH, then if your dependancies are correct, numpy should just work.

Upvotes: 1

Related Questions