简体   繁体   English

尝试运行/启动 Flask 应用程序时出现 python 导入错误

[英]python import error when attempting to run / launch Flask application

My Flask Application was working alright and all of a sudden I am seeing this error when I run the command to launch the App locally.我的 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'

I tried upgrading pandas and numpy , but it didn't fix the issue.我尝试升级pandasnumpy ,但没有解决问题。

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

I've had similar issues to this when deploying flask apps on servers with different environments, here is something I've done that worked in the past in case this helps:在具有不同环境的服务器上部署 Flask 应用程序时,我遇到了类似的问题,这是我过去做过的一些工作,以防万一:

Uninstall the package then reinstall specific version using the absolute path to the python executable.卸载软件包,然后使用 python 可执行文件的绝对路径重新安装特定版本。

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

Hope that may help.希望这可能会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM