代码之家  ›  专栏  ›  技术社区  ›  aerin

importorror:没有名为“numpy”的模块,但它在那里!蟒蛇3.5

  •  0
  • aerin  · 技术社区  · 7 年前

    我错过了什么?有人能在这里启发我吗?

    第一步。我正在安装numpy。

    aerin@aerin-hp-z230-tower-workstation:~$sudo pip安装numpy

    >     The directory '/home/aerin/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been
    > disabled. Please check the permissions and owner of that directory. If
    > executing pip with sudo, you may want sudo's -H flag.
    >     The directory '/home/aerin/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled.
    > check the permissions and owner of that directory. If executing pip
    > with sudo, you may want sudo's -H flag.
    >     Requirement already satisfied: numpy in /usr/local/lib/python3.5/dist-packages
    >     You are using pip version 9.0.3, however version 10.0.1 is available.
    >     You should consider upgrading via the 'pip install --upgrade pip' command.
    

    第二步。好啊。它说它在里面 /usr/local/lib/python3.5/dist-packages 是的。所以让我们使用numpy。

    aerin@aerin-HP-Z230-Tower-Workstation:~$ python3
    Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
    [GCC 5.4.0 20160609] on linux
    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'
    

    第三步。你在开玩笑吗?让我们看看它在哪里导入包。

    >import site; site.getsitepackages()
    
    ['/usr/local/lib/python3.5/dist-packages', '/usr/lib/python3/dist-packages', '/usr/lib/python3.5/dist-packages']
    

    你说它在那儿,但它让我很害怕!如果有人告诉我去哪儿看,我会很感激的。谢谢!

    2 回复  |  直到 7 年前
        1
  •  0
  •   MFK34    7 年前

    不确定,但我认为你应该尝试:

    sudo pip3 install numpy
    

    如果这不起作用,请尝试为python2&3重新安装numpy

        2
  •  0
  •   Sunitha    7 年前

    尝试升级pip并重新安装numpy

    sudo pip install --upgrade pip
    sudo pip install --reinstall numpy