我在本地计算机上运行时,我的应用程序运行正常。但是,只要我将其上传到服务器上,manage.py就会出现以下错误 -
文件“manage.py”,第14行 来自exc ^ SyntaxError:语法无效
这是manage.py的代码 -
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "chatbot.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc ***//Here is the error***
execute_from_command_line(sys.argv)
我正在使用Python 2.7和Django 1.11
答案 0 :(得分:0)
请参考以下链接:How to solve SyntaxError on autogenerated manage.py?
我从上面的链接中学到的是,如果我们有两个版本的python,则需要指定运行应用程序的版本,如下所示:
python3 manage.py runserver