如何解决ImportError:pycharm中没有名为“ numpy.matrixlib”的模块?

时间:2019-05-15 05:38:30

标签: python numpy pycharm

当我使用PyCharm时,突然向我显示下面的ImportError(以及许多其他错误)。我认为没有必要在PyCharm IDE中添加numpy。那你能帮我解决这个问题吗?

我尝试使用其他python版本来解决此问题,但没有帮助。

代码是:

import numpy as np
import time

import sys

S = range(1000)
print(sys.getsizeof(5) * len(S))

D = np.arange(1000)
print(D.size * D.itemsize)

我在上面的代码中遇到此错误:

Traceback (most recent call last):
  File "<input>", line 3, in <module>
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.2\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197, in runfile
    pydev_imports.execfile(filename, global_vars, local_vars)  # execute the script
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.2\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "D:/pyprog/test].py", line 2, in <module>
    import numpy as np
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.2\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "D:\pyprog\venv\lib\site-packages\numpy\__init__.py", line 145, in <module>
    from . import lib
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.2\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.2\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "D:\pyprog\venv\lib\site-packages\numpy\lib\__init__.py", line 9, in <module>
    from .index_tricks import *
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.2\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "D:\pyprog\venv\lib\site-packages\numpy\lib\index_tricks.py", line 13, in <module>
    import numpy.matrixlib as matrixlib
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.2\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
ImportError: No module named 'numpy.matrixlib'

1 个答案:

答案 0 :(得分:0)

这是在numpy中安装virtualenv的问题。请参阅this question(Linux)或this question(Windows)以获取有关如何在numpy中安装venv或将非虚拟化运行时与numpy一起使用的说明。已安装。