How can I upgrade NumPy?

后端 未结 12 1931
太阳男子
太阳男子 2020-12-01 04:31

When I installed OpenCV using Homebrew (brew), I got this problem whenever I run this command to test python -c \"import cv2\":

Run         


        
相关标签:
12条回答
  • 2020-12-01 04:35

    Because we have two NumPy installations in the system. One is installed by Homebrew and the second is installed by pip. So in order to solve the problem, we need to delete one and use the default NumPy install by OpenCV.

    Check the path,

    import numpy
    print numpy.__path__
    

    and manually delete it using rm.

    0 讨论(0)
  • 2020-12-01 04:38

    I tried doing sudo pip uninstall numpy instead, because the rm didn't work at first.

    Hopefully that helps.

    Uninstalling then to install it again.

    0 讨论(0)
  • 2020-12-01 04:43

    If you don't encounter any permission errors with

    pip install -U numpy
    

    try:

    pip install --user -U numpy
    
    0 讨论(0)
  • 2020-12-01 04:46

    When you already have an older version of NumPy, use this:

    pip install numpy --upgrade
    

    If it still doesn't work, try:

    pip install numpy --upgrade --ignore-installed
    
    0 讨论(0)
  • 2020-12-01 04:46

    If you are stuck with a machine where you don't have root access, then it is better to deal with a custom Python installation.

    The Anaconda installation worked like a charm:

    • Installing packages (SciPy.org)
    • Anaconda Python/R Distribution - download

    After installation,

    [bash]$ /xxx/devTools/python/anaconda/bin/pip list --format=columns | grep numpy

    numpy 1.13.3 numpydoc 0.7.0

    0 讨论(0)
  • 2020-12-01 04:48

    Because you have multiple versions of NumPy installed.

    Try pip uninstall numpy and pip list | grep numpy several times, until you see no output from pip list | grep numpy.

    Then pip install numpy will get you the newest version of NumPy.

    0 讨论(0)
提交回复
热议问题