我正在使用一个名为investpy的模块,numpy是它的依赖项。我尝试运行 pip installinvestpy,它安装了所有依赖项(或者它是这样说的)。然而,当我尝试跑步时
import numpy
或
import investpy
,我面临这个错误:
Traceback (most recent call last):
File "C:\Users\kakor\OneDrive\Desktop\ML\numpy\__init__.py", line 124, in <module>
from numpy.__config__ import show as show_config
ModuleNotFoundError: No module named 'numpy.__config__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\kakor\OneDrive\Desktop\ML\stockscreener.py", line 1, in <module>
import numpy
File "C:\Users\kakor\OneDrive\Desktop\ML\numpy\__init__.py", line 129, in <module>
raise ImportError(msg)
ImportError: Error importing numpy: you should not try to import numpy from
its source directory; please exit the numpy source tree, and relaunch
your python interpreter from there.
我真的很困惑为什么会发生这种情况,因为据我所知,我正确安装了 numpy。此外,这真的很奇怪,因为如果我进入 cmd 中的 python 目录并运行 import numpy,它就可以完美运行。
任何帮助将不胜感激。谢谢!
本质上 numpy 似乎抱怨它不是从标准路径导入的。 看起来您已将 numpy 直接安装到项目目录下的
C:\Users\kakor\OneDrive\Desktop\ML\numpy
下,您应该删除该目录并尝试运行
pip install numpy