0

我创建了一个虚拟环境(在此示例中名为“ML”),几天后总是得到相同的错误:

 File "/Users/michaelomelveny/Desktop/ML_maybe/ML/lib/python3.8/site-packages/numpy/core/__init__.py", line 22, in <module>
    from . import multiarray
  File "/Users/michaelomelveny/Desktop/ML_maybe/ML/lib/python3.8/site-packages/numpy/core/multiarray.py", line 12, in <module>
    from . import overrides
  File "/Users/michaelomelveny/Desktop/ML_maybe/ML/lib/python3.8/site-packages/numpy/core/overrides.py", line 7, in <module>
    from numpy.core._multiarray_umath import (
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'

在处理上述异常的过程中,又出现了一个异常:

Traceback (most recent call last):
  File "/Users/michaelomelveny/Desktop/ML_maybe/linear_regression.py", line 1, in <module>
    import numpy as np
  File "/Users/michaelomelveny/Desktop/ML_maybe/ML/lib/python3.8/site-packages/numpy/__init__.py", line 140, in <module>
    from . import core
  File "/Users/michaelomelveny/Desktop/ML_maybe/ML/lib/python3.8/site-packages/numpy/core/__init__.py", line 48, in <module>
    raise ImportError(msg)
ImportError: 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.8 from "/Users/michaelomelveny/Desktop/ML_maybe/ML/bin/python"
  * The NumPy version is: "1.19.5"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: No module named 'numpy.core._multiarray_umath'

我在 Visual Studio Code 中工作,当我将解释器路径更改为以下时,我的代码将编译:

/usr/local/bin/python3

当我将解释器路径更改为以下时,我得到的错误是以下“No module named 'numpy'”:

/usr/bin/python3

我对上述结果感到困惑,因为我只将 NumPy 安装到给我初始错误的虚拟环境中。我使用以下命令将 numpy 以及任何其他包安装到虚拟环境:

pip3 install numpy

这发生在我创建的任何虚拟环境中。在我收到此错误之前,我的脚本正在编译,没有任何问题;错误总是与 Numpy 相关。我正在使用 Mac OSX 计算机。提前感谢任何人。

4

0 回答 0