I doubt that you really do need, or want, to downgrade NumPy.
But that's not what your question is really about. You want to know why pip
is showing one thing and python
is showing another, and what you can do about that.
The reason you're seeing different things is that your pip
doesn't go with your python
.
When you run python
, that's your Python 2.7, and packages you import
there come from your 2.7 library, at /usr/local/lib/python2.7/
.
When you run pip
it's using your Python 3.4, and installing and looking for things in your Python 3.4's library, which is at /usr/local/lib/python3.4/
.
So, pip show numpy
is showing you the version of NumPy your Python 3.4 has, which is completely independent of the version of NumPy your Python 2.7 has.
If you didn't intend to use Python 2.7, the solution is to run Python 3.4 instead, usually just by using python3
instead of python
.
If you did intend to use Python 2.7, the solution is to use the pip
that goes with it. You may have a command named pip2
or pip2.7
for this, but the safest way is to use python -m pip
instead of pip
.
As a side note, given where your 3.4 NumPy is installed, it looks like you may have done something like apt-get python3-numpy
or yum python-numpy
or similar to install it, not pip install numpy
. And probably something like apt-get python2-numpy
to get the 2.7 version as well. If so, you may want to downgrade or upgrade it the same way you installed it in the first place, using your distro's package manager, instead of using pip
. If not… then ignore this paragraph.
If this all seems way too complicated, but you really do need to have both Python 2.7 and Python 3.4 around, there are two things you should consider:
- Always use virtual environments. Whenever possible, don't install anything globally; pick an environment to install it in. Whatever environment is active,
python
and pip
will both be for that environment.
- Install the latest version of Anaconda, with the latest version of Python (3.7 as of today), then ask it to install 3.4 and 2.7 conda environments. Use those environments, and never even touch your system 3.4 and 2.7.