【问题标题】:showing syntax error when trying to run in pycharm尝试在 pycharm 中运行时显示语法错误
【发布时间】:2015-02-21 05:43:39
【问题描述】:

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

"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

这发生在所有项目中。这个问题意外开始...

【问题讨论】:

  • 你安装的是什么版本的 Python 2.7?
  • python 2.7.8 但 pycharm 一开始运行良好...

标签: django python-2.7 pycharm


【解决方案1】:

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

【讨论】:

  • 好的,后来我重新安装了 pycharm,但现在我重新安装了 django,现在它可以正常工作了。谢谢大家......
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-02-05
  • 2020-04-20
  • 1970-01-01
  • 2021-07-29
  • 1970-01-01
  • 2021-01-26
  • 2021-05-27
相关资源
最近更新 更多