Debian No Module named numpy
Question: I've installed Python Numpy on Debian using...

> apt-get install python-numpy

But when run the Python shell I get the following...

    
    
    Python 2.7.10 (default, Sep  9 2015, 20:21:51)
    [GCC 4.9.2] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import numpy
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: No module named numpy
    

When I view the contents of `/usr/local/lib/python2.7/site-packages/` I
noticed numpy is not list.

If I install it via pip i.e `pip install numpy` it works just fine, However, I
want to use the apt-get method. What I'm I doing wrong?

Other:

> echo $PYTHONPATH /usr/local/lib/python2.7

dpkg -l python-numpy...

    
    
    Desired=Unknown/Install/Remove/Purge/Hold
    | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
    |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
    ||/ Name                                            Version                      Architecture                 Description
    +++-===============================================-============================-============================-====================================================================================================
    ii  python-numpy                                    1:1.8.2-2                    amd64                        Numerical Python adds a fast array facility to the Python language
    

> Python 2.7.10
    
    
    ['', '/usr/local/lib/python2.7', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7/plat-linux2', '/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old', '/usr/local/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/site-packages']
    

which -a python...

    
    
    /usr/local/bin/python
    /usr/bin/python
    

echo $PATH

    
    
    /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    


Answer: As you can tell from your `which` result, the python you are running when just
typing `python` is `/usr/local/bin/python`.

It's a python you probably installed there yourself, as [Debian will never put
anything in `/usr/local`](https://www.debian.org/doc/debian-policy/ch-
opersys.html#s9.1.2) by itself (except for empty directories).

How? Well, by running `pip` for instance. As a rule, you should never use
`pip` outside of a [virtualenv](http://docs.python-
guide.org/en/latest/dev/virtualenvs/), because it will install stuff on your
system that your package manager will not know about. And maybe break stuff,
like what you see on your system.

So, if you run `/usr/bin/python`, it should see the numpy package you
installed using your package manager.

How to fix it? Well, I would clear anything in `/usr/local` (beware, it will
definitely break stuff that rely on things you installed locally). Then I
would `apt-get install python-virtualenv`, and always work with a virtualenv.

    
    
    $ virtualenv -p /usr/bin/python env
    $ . env/bin/activate
    (env)$ pip install numpy
    (env)$ python
    >>> import numpy
    >>>
    

That way, packages will be installed in the `env` directory. You do all this
as a regular user, not root. And your different projects can have different
environments with different packages installed.

