从Linux终端运行Python脚本到LocalHost

时间:2021-03-04 17:31:02

I am working through Miguel Grinberg's Flask Mega-Tutorial and am unable to run the basic Hello World Flask app in Local Host:

我正在通过Miguel Grinberg的Flask Mega-Tutorial工作,我无法在本地主机中运行基本的Hello World Flask应用程序:

run.py:

#!flask/bin/python
from app import app
app.run(debug = True)

I am running the following in the Ubuntu terminal:

我在Ubuntu终端中运行以下代码:

chmod a+x run.py
./run.py

Which is generating the following:

这产生以下因素:

bash: ./run.py: flask/bin/python: bad interpreter: No such file or directory

Appreciate the input.

欣赏输入。

1 个解决方案

#1


1  

You may have not created yet the virtual environment called "flask" (explained under the Installing Flask section), therefore the shebang line fails. I ran it without and with the virtenv and it works.

您可能尚未创建名为“flask”的虚拟环境(在“安装Flask”部分下进行了解释),因此shebang行失败。我没有和virtenv运行它,它的工作原理。

Check this topic to see if it helps: flask/bin/pip install flask==0.9 results in 'no such file or directory'.

检查此主题以查看它是否有帮助:flask / bin / pip install flask == 0.9导致'无此文件或目录'。

#1


1  

You may have not created yet the virtual environment called "flask" (explained under the Installing Flask section), therefore the shebang line fails. I ran it without and with the virtenv and it works.

您可能尚未创建名为“flask”的虚拟环境(在“安装Flask”部分下进行了解释),因此shebang行失败。我没有和virtenv运行它,它的工作原理。

Check this topic to see if it helps: flask/bin/pip install flask==0.9 results in 'no such file or directory'.

检查此主题以查看它是否有帮助:flask / bin / pip install flask == 0.9导致'无此文件或目录'。