I'm new to python and ubuntu. I installed two versions of python to be able to use them in jupyter .. but when i checked the version of numpy i got

import numpy 

and got

>>> numpy.__version__

but when i used

pip show numpy
Name: numpy
Version: 1.11.0
Summary: NumPy: array processing for numbers, strings, records, and 
Home-page: http://www.numpy.org
Author: NumPy Developers
Author-email: numpy-discussion@scipy.org
License: BSD
Location: /usr/local/lib/python3.4/dist-packages

and the

 python3 -m pip --version
 pip --version 


 pip 18.0 from /usr/local/lib/python3.4/dist-packages/pip (python 3.4)


 python -m pip --version


 pip 18.0 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)

now i'm confusing with both versions . i got error with

slice indices must be integers or None or have an __index__ method

and found that because i need to downgrade numpy but i found two and don't know which one i should use ?


Do not use the pip command directly, because it's ambiguous which instance of the Python package manager this command is referring to under some circumstances. I think it will be the one you installed/upgraded last.

You should preferably call it as a Python module instead, like one of these, depending on whether you want pip for Python 2 or 3:

python -m pip
python3 -m pip

That way you can always be sure you get the package manager for the right Python installation you want.

To e.g. install numpy for Python 3, you would now run

python3 -m pip install numpy
  • thanks for replying , but do you mean like that python -m pip numpy ? – sam Aug 19 '18 at 1:51
  • Instead of pip install numpy you would now say python -m pip install numpy (or python3 -m pip install numpy). Basically all you do is prefixing your "traditional" pip command with python -m/python3 -m. – Byte Commander Aug 19 '18 at 9:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.