试图运行/启动Flask应用程序时发生python导入错误



我的Flask应用程序运行正常,当我运行命令在本地启动应用程序时,突然看到了这个错误。

File "/Flask_Trial_App2/index.py", line 6, in <module>
import pandas as pd
File "/Flask_Trial_App/virt/lib/python3.8/site-packages/pandas/__init__.py", line 16, in <module>
raise ImportError(
ImportError: Unable to import required dependencies:
numpy: 
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 "/Flask_Trial_App/virt/bin/python"
* The NumPy version is: "1.21.1"
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'

我尝试升级pandasnumpy,但没有解决问题。

pip install --upgrade numpy
pip install --upgrade pandas

在不同环境的服务器上部署flask应用程序时,我也遇到过类似的问题,以下是我过去做过的一些工作,以防有帮助:

卸载程序包,然后使用python可执行文件的绝对路径重新安装特定版本。

/Flask_Trial_App/virt/bin/python3 -m pip uninstall numpy; /Flask_Trial_App/virt/bin/python3 -m pip install numpy==1.21.1

希望这能有所帮助。

最新更新