由于python运行程序上的语法错误,无法运行py文件

时间:2019-08-06 06:47:36

标签: python flask

尝试运行py文件时出现语法错误。

Traceback (most recent call last):
  File "/home/ubuntu/environment/run.py", line 2, in <module>
    from flask import Flask
  File "/home/ubuntu/.local/lib/python3.6/site-packages/flask/__init__.py", line 14, in <module>
    from jinja2 import escape
  File "/home/ubuntu/.local/lib/python3.6/site-packages/jinja2/__init__.py", line 82, in <module>
    _patch_async()
  File "/home/ubuntu/.local/lib/python3.6/site-packages/jinja2/__init__.py", line 78, in _patch_async
    from jinja2.asyncsupport import patch_all
  File "/home/ubuntu/.local/lib/python3.6/site-packages/jinja2/asyncsupport.py", line 13, in <module>
    import asyncio
  File "/usr/lib/python3.6/asyncio/__init__.py", line 21, in <module>
    from .base_events import *
  File "/usr/lib/python3.6/asyncio/base_events.py", line 17, in <module>
    import concurrent.futures
  File "/usr/local/lib/python2.7/dist-packages/concurrent/futures/__init__.py", line 8, in <module>
    from concurrent.futures._base import (FIRST_COMPLETED,
  File "/usr/local/lib/python2.7/dist-packages/concurrent/futures/_base.py", line 414
    raise exception_type, self._exception, self._traceback
                        ^
SyntaxError: invalid syntax

导致此问题的代码如下:

import os
from flask import Flask
app = Flask(__name__)
@app.route('/')

def hello():
    return "Hello World"

if __name__ == '__main__':
    app.run(host=os.environ.get('IP'),
            port=int(os.environ.get('PORT')),
            debug=True)

0 个答案:

没有答案