用pycharm创建django项目时报错该怎么解决?

发布于 2022-09-12 00:27:56 字数 5384 浏览 16 评论 0

用pycharm创建django项目时报错该怎么解决?

Error creating Django application: Error on python side. Exit code: 1, err: Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Users\座山雕\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "C:\Users\座山雕\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py", line 338, in execute
    django.setup()
  File "C:\Users\座山雕\AppData\Local\Programs\Python\Python37\lib\site-packages\django\__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Users\座山雕\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "C:\Users\座山雕\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\config.py", line 94, in create
    module = import_module(entry)
  File "C:\Users\座山雕\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\座山雕\AppData\Local\Programs\Python\Python37\lib\site-packages\django\contrib\admin\__init__.py", line 4, in <module>
    from django.contrib.admin.filters import (
  File "C:\Users\座山雕\AppData\Local\Programs\Python\Python37\lib\site-packages\django\contrib\admin\filters.py", line 10, in <module>
    from django.contrib.admin.options import IncorrectLookupParameters
  File "C:\Users\座山雕\AppData\Local\Programs\Python\Python37\lib\site-packages\django\contrib\admin\options.py", line 12, in <module>
    from django.contrib.admin import helpers, widgets
  File "C:\Users\座山雕\AppData\Local\Programs\Python\Python37\lib\site-packages\django\contrib\admin\widgets.py", line 151
    '%s=%s' % (k, v) for k, v in params.items(),
    ^
SyntaxError: Generator expression must be parenthesized
 out: 

问题描述

用pycharm创建django项目时报错该怎么解决?

问题出现的平台版本及自己尝试过哪些方法

重装Django也没用

相关代码

// 请把代码文本粘贴到下方(请勿用图片代替代码)
Error creating Django application: Error on python side. Exit code: 1, err: Traceback (most recent call last):
File "manage.py", line 22, in <module>

execute_from_command_line(sys.argv)

File "C:Users座山雕AppDataLocalProgramsPythonPython37libsite-packagesdjangocoremanagement__init__.py", line 364, in execute_from_command_line

utility.execute()

File "C:Users座山雕AppDataLocalProgramsPythonPython37libsite-packagesdjangocoremanagement__init__.py", line 338, in execute

django.setup()

File "C:Users座山雕AppDataLocalProgramsPythonPython37libsite-packagesdjango__init__.py", line 27, in setup

apps.populate(settings.INSTALLED_APPS)

File "C:Users座山雕AppDataLocalProgramsPythonPython37libsite-packagesdjangoappsregistry.py", line 85, in populate

app_config = AppConfig.create(entry)

File "C:Users座山雕AppDataLocalProgramsPythonPython37libsite-packagesdjangoappsconfig.py", line 94, in create

module = import_module(entry)

File "C:Users座山雕AppDataLocalProgramsPythonPython37libimportlib__init__.py", line 127, in import_module

return _bootstrap._gcd_import(name[level:], package, level)

File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:Users座山雕AppDataLocalProgramsPythonPython37libsite-packagesdjangocontribadmin__init__.py", line 4, in <module>

from django.contrib.admin.filters import (

File "C:Users座山雕AppDataLocalProgramsPythonPython37libsite-packagesdjangocontribadminfilters.py", line 10, in <module>

from django.contrib.admin.options import IncorrectLookupParameters

File "C:Users座山雕AppDataLocalProgramsPythonPython37libsite-packagesdjangocontribadminoptions.py", line 12, in <module>

from django.contrib.admin import helpers, widgets

File "C:Users座山雕AppDataLocalProgramsPythonPython37libsite-packagesdjangocontribadminwidgets.py", line 151

'%s=%s' % (k, v) for k, v in params.items(),
^

SyntaxError: Generator expression must be parenthesized
out:

你期待的结果是什么?实际看到的错误信息又是什么?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心不设防 2022-09-19 00:27:56

你的django跟python分别是什么版本?
django-1.11.16及以下的版本在使用python3.7解释器的时候会出现“Generator expression must be parenthesized”这个问题。
如果是上述版本问题,你可以升级一下django,到2.0以上,或者到1.11.17。

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文