尝试在pycharm中运行时显示语法错误

时间:2014-12-23 04:58:45

标签: django python-2.7 pycharm

当我尝试运行项目时,它显示以下消息:

"C:\Program Files (x86)\JetBrains\PyCharm 3.4.1\bin\runnerw.exe" C:\Python27\python.exe G:/project/sample3/manage.py runserver 8000
Traceback (most recent call last):
  File "G:/project/sample3/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Python27\lib\site-packages\django-1.7.1-py2.7.egg\django\core\management\__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "C:\Python27\lib\site-packages\django-1.7.1-py2.7.egg\django\core\management\__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python27\lib\site-packages\django-1.7.1-py2.7.egg\django\core\management\__init__.py", line 238, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "C:\Python27\lib\site-packages\django-1.7.1-py2.7.egg\django\core\management\__init__.py", line 41, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
  File "C:\Python27\lib\site-packages\django-1.7.1-py2.7.egg\django\contrib\staticfiles\management\commands\runserver.py", line 18
    def get_handler(self, *args, use_static_handler=True, insecure_serving=False, **options):
                                                  ^
SyntaxError: invalid syntax

Process finished with exit code 1

所有项目都会发生这种情况。这个问题意外地开始......

1 个答案:

答案 0 :(得分:1)

看起来您可能在安装中意外修改了Django代码,因为这不是line 18 of this file在实际Django源代码中的样子。请尝试卸载并重新安装Django。