我正在尝试用PyCharm开发一个SPA,它使用venv作为我的项目的虚拟环境。
我遵循了本教程的https://auth0.com/blog/using-python-flask-and-angular-to-build-modern-apps-part-1/,但配置是基于linux系统的。我陷入了从命令行运行bootstrap脚本来运行flask应用程序的阶段。
将其放入PowerShell脚本似乎是合理的,因为我是在Windows10上开发的,但我无法在venv中运行此脚本。
脚本本身只包含以下内容:
$env:FLASK_APP = "./src/main.py“
烧瓶运行-h 0.0.0.0
现在,在venv中,我只能启动一个PowerShell终端。实际上我不能直接从venv中运行这个脚本。如果我从PowerShell中导航到venv文件夹,我的脚本将是可执行的,但它显然无法工作,因为flask只能在venv中使用。
那么,谁能告诉我在venv中运行脚本的最佳实践,这个脚本将运行我的flask应用程序?
发布于 2019-08-05 14:11:09
您可以使用以下命令对pipenv进行点源代码:
cd YourProjectPath
$venv = pipenv --venv
. "$venv\scripts\activate.ps1"
#"rest of your script"
$env:FLASK_APP = "./src/main.py"
flask run -h 0.0.0.0如果你直接使用venv,那么:
. .\your env name\Scripts\Activate.ps1
#"rest of your script"
$env:FLASK_APP = "./src/main.py"
flask run -h 0.0.0.0https://stackoverflow.com/questions/57347458
复制相似问题