简体   繁体   English

Flask 在 Windows 上运行时无法识别 python-dotenv

[英]Flask run not recognizing python-dotenv on windows

So I'm running python 3.7 on Windows and I have installed python-dotenv in my virtual environment as well as flask.所以我在 Windows 上运行 python 3.7,并且在我的虚拟环境和烧瓶中安装了 python-dotenv。 I have a.flaskenv file in the root of my project where I execute flask run, it looks as if python/flask is not recognizing python-dotenv.flaskenv file it ignores my parameters and states that I do not have a FLASK_APP value assigned.我在执行 flask run 的项目根目录中有一个 .flaskenv 文件,它看起来好像 python/flask 无法识别 python-dotenv.flaskenv 文件,它忽略了我的参数并声明我没有分配 FLASK_APP 值。 This same setup works fine on a Linux workstation.同样的设置在 Linux 工作站上运行良好。 Is there something different to configure on windows to get this to work?在 Windows 上有什么不同的配置来让它工作吗?

Thanks ahead of time.提前致谢。

I ran into the same issue and resolved it by executing python -m flask run instead of flask run .我遇到了同样的问题并通过执行python -m flask run而不是flask run解决了这个问题。 The -m allows modules to be located and executed. -m 允许定位和执行模块。

.flaskenv seems to be working fine on Windows 10. Have you tried creating a new file named.flaskenv, without specifying any extension, in Visual Studio Code? .flaskenv 似乎在 Windows 10 上运行良好。您是否尝试在 Visual Studio Code 中创建一个名为 .flaskenv 的新文件,而不指定任何扩展名? A.flaskenv file of FLASKENV FILE type gets automatically created. FLASKENV FILE 类型的 A.flaskenv 文件会自动创建。 I have in there a single line FLASK_APP=yourFileName.py.我在那里有一行 FLASK_APP=yourFileName.py。 Hope this helps.希望这可以帮助。

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

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