How can I upgrade Numpy in just one version of Python?

14,137

Forgive me as I am on a mac, but I think a similar command should work on windows:

<path/to/particular/version/of/python> -m pip install numpy==<version number>

As an example from my machine:

$ # numpy versions before changes
$ python3.6 -m pip list | grep numpy
numpy                  1.14.5
$ python3.7 -m pip list | grep numpy
numpy                    1.15.2

$ # updating numpy for python3.6
$ python3.6 -m pip install numpy==1.16.1
.
.
.

$ # numpy versions after changes
$ python3.6 -m pip list | grep numpy
numpy                  1.16.1
$ python3.7 -m pip list | grep numpy
numpy                    1.15.2
Share:
14,137
Bob Samuels
Author by

Bob Samuels

Updated on June 04, 2022

Comments

  • Bob Samuels
    Bob Samuels almost 2 years

    I am trying to get OpenCV working, but the issue with this is that my Python27 Numpp version is too old. Every time I write "install --upgrade numpy", I am told that Numpy is already up to date in C:Python37. How can I update Numpy in C:Python27 rather than 37? Any help would be much appreciated.

    • bnaecker
      bnaecker about 5 years
      The version of pip is tied to a specific Python installation. So pip on my computer works for Python 3.7, while pip2 is for Python 2.7. Are you sure you're using the correct version of pip.
    • Bob Samuels
      Bob Samuels about 5 years
      @bnaecker I am using pip3, I think this is the issue. My computer doesn't seem to recognize 'pip2'. How can I run install numpy using pip2?
    • bnaecker
      bnaecker about 5 years
      It may just be called pip on your machine. If you do pip --version, that will tell you exactly which version. It may also be called pip2.7 or something more specific.
    • Bob Samuels
      Bob Samuels about 5 years
      Okay, thanks! I'll try that
  • Shariq
    Shariq about 5 years
    If you only want to use python27, you can also set it default globally by editing Environment Variables.