SyntaxError:Generator表达式必须是parenthezised / python manage.py migrate

时间:2022-03-21 18:05:07

I'm really new in programming and I wanted to follow the Djangogirls tutorial, but I'm stucked now. In the tutorial, I am here:

我是编程新手,我想跟随Djangogirls教程,但我现在被困了。在教程中,我在这里:

To create a database for our blog, let's run the following in the console: python manage.py migrate (we need to be in the djangogirls directory that contains the manage.py file). If that goes well, you should see something like this: ...

要为我们的博客创建数据库,让我们在控制台中运行以下命令:python manage.py migrate(我们需要在包含manage.py文件的djangogirls目录中)。如果情况顺利,你应该看到这样的事情:......

There is no option to fail in the tutorial but I have an error message:

在教程中没有失败的选项,但我有一条错误消息:

(myvenv) C:\Users\Julcsi\djangogirls> python manage.py migrate
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\Julcsi\djangogirls\myvenv\lib\site-packages\django\core\management\__init__.py", 
line 364, in execute_from_command_line
utility.execute()
File "C:\Users\Julcsi\djangogirls\myvenv\lib\site-packages\django\core\management\__init__.py", 
line 338, in execute
django.setup()
File "C:\Users\Julcsi\djangogirls\myvenv\lib\site-packages\django\__init__.py", 
line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\Julcsi\djangogirls\myvenv\lib\site-packages\django\apps\registry.py", 
line 85, in populate
app_config = AppConfig.create(entry)
File "C:\Users\Julcsi\djangogirls\myvenv\lib\site-packages\django\apps\config.py", 
line 94, in create
module = import_module(entry)
File "C:\Users\Julcsi\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 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 723, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_remove
File "C:\Users\Julcsi\djangogirls\myvenv\lib\site-packages\django\contrib\admin\__init__.py", 
line 4, in <module>
from django.contrib.admin.filters import (
File "C:\Users\Julcsi\djangogirls\myvenv\lib\site-packages\django\contrib\admin\filters.py", 
line 10, in <module>
from django.contrib.admin.options import IncorrectLookupParameters
File "C:\Users\Julcsi\djangogirls\myvenv\lib\site-packages\django\contrib\admin\options.py", 
line 12, in <module>
from django.contrib.admin import helpers, widgets
File "C:\Users\Julcsi\djangogirls\myvenv\lib\site-packages\django\contrib\admin\widgets.py", 
line 152
'%s=%s' % (k, v) for k, v in params.items(),
SyntaxError: Generator expression must be parenthesized

What am I doing wrong? What should I do?

我究竟做错了什么?我该怎么办?

I have Python 3.7.0b1

我有Python 3.7.0b1

Thanks a lot in advance for the help :)

非常感谢提前帮助:)

3 个解决方案

#1


19  

You’re not doing anything wrong; this is a problem between Django and Python 3.7. Django has a fix, but that fix hasn’t made it into a new version yet.

你没有做错任何事;这是Django和Python 3.7之间的问题。 Django有一个修复,但该修复尚未成为新版本。

You can install the stable version of Python, Python 3.6, in the meantime.

在此期间,您可以安装稳定版本的Python,Python 3.6。

#2


1  

The Django Girls tutorial version in English has just switched to Django 2.0 which should make it compatible to Python 3.7. (Django 2.0 includes a backport of the fix mentioned in Ry-'s answer.)

Django Girls教程的英文版刚刚切换到Django 2.0,它应该与Python 3.7兼容。 (Django 2.0包含了Ry的答案中提到的修复的后端。)

So everyone beginning the tutorial now should be fine with Python 3.7.

因此,现在开始本教程的每个人都应该使用Python 3.7。

If you've already begun the tutorial you'd have to start again at the Django installation chapter. You'll want to do that in a new directory (either delete or rename your current djangogirls directory or choose a different name for the new directory) as the files generated by

如果您已经开始学习本教程,则必须在Django安装章节重新开始。您将要在新目录中执行此操作(删除或重命名当前的djangogirls目录或为新目录选择其他名称)作为生成的文件

django-admin print startproject mysite .

depend on the Django version in use.

取决于使用的Django版本。

#3


1  

Also, upgrading Django solved my problem

此外,升级Django解决了我的问题

On your terminal,

在你的终端上,

$ pip install -U Django

or see here

或者看这里

#1


19  

You’re not doing anything wrong; this is a problem between Django and Python 3.7. Django has a fix, but that fix hasn’t made it into a new version yet.

你没有做错任何事;这是Django和Python 3.7之间的问题。 Django有一个修复,但该修复尚未成为新版本。

You can install the stable version of Python, Python 3.6, in the meantime.

在此期间,您可以安装稳定版本的Python,Python 3.6。

#2


1  

The Django Girls tutorial version in English has just switched to Django 2.0 which should make it compatible to Python 3.7. (Django 2.0 includes a backport of the fix mentioned in Ry-'s answer.)

Django Girls教程的英文版刚刚切换到Django 2.0,它应该与Python 3.7兼容。 (Django 2.0包含了Ry的答案中提到的修复的后端。)

So everyone beginning the tutorial now should be fine with Python 3.7.

因此,现在开始本教程的每个人都应该使用Python 3.7。

If you've already begun the tutorial you'd have to start again at the Django installation chapter. You'll want to do that in a new directory (either delete or rename your current djangogirls directory or choose a different name for the new directory) as the files generated by

如果您已经开始学习本教程,则必须在Django安装章节重新开始。您将要在新目录中执行此操作(删除或重命名当前的djangogirls目录或为新目录选择其他名称)作为生成的文件

django-admin print startproject mysite .

depend on the Django version in use.

取决于使用的Django版本。

#3


1  

Also, upgrading Django solved my problem

此外,升级Django解决了我的问题

On your terminal,

在你的终端上,

$ pip install -U Django

or see here

或者看这里