django – 使用python 3.7的Docker错误:生成器表达式必须括起来

django – 使用python 3.7的Docker错误:生成器表达式必须括起来,第1张

概述嗨,我正在关注…的 django教程( Quickstart: Compose and Django),我有这个错误: SyntaxError: Generator expression must be parenthesized 追溯 root@localhost:~# docker-compose upStarting root_db_1 ... doneStarting root_web 嗨,我正在关注…的 django教程( @L_419_1@),我有这个错误:

SyntaxError: Generator Expression must be parenthesized

追溯

root@localhost:~# docker-compose upStarting root_db_1 ... doneStarting root_web_1 ... doneAttaching to root_db_1,root_web_1db_1   | 2018-09-09 00:09:10.440 UTC [1] LOG:  Listening on IPv4 address "0.0.0.0",port 5432db_1   | 2018-09-09 00:09:10.440 UTC [1] LOG:  Listening on IPv6 address "::",port 5432db_1   | 2018-09-09 00:09:10.442 UTC [1] LOG:  Listening on Unix socket "/var/run/postgresql/.s.PGsql.5432"db_1   | 2018-09-09 00:09:10.481 UTC [21] LOG:  database system was interrupted; last kNown up at 2018-09-09 00:06:36 UTCdb_1   | 2018-09-09 00:09:10.597 UTC [21] LOG:  database system was not properly shut down; automatic recovery in progressdb_1   | 2018-09-09 00:09:10.599 UTC [21] LOG:  redo starts at 0/1633C88db_1   | 2018-09-09 00:09:10.599 UTC [21] LOG:  invalID record length at 0/1633CC0: wanted 24,got 0db_1   | 2018-09-09 00:09:10.599 UTC [21] LOG:  redo done at 0/1633C88db_1   | 2018-09-09 00:09:10.632 UTC [1] LOG:  database system is ready to accept connectionsweb_1  | Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f652d99d510>web_1  | Traceback (most recent call last):web_1  |   file "/usr/local/lib/python3.7/site-packages/django/utils/autoreload.py",line 228,in wrapperweb_1  |     fn(*args,**kwargs)web_1  |   file "/usr/local/lib/python3.7/site-packages/django/core/management/commands/runserver.py",line 116,in inner_runweb_1  |     autoreload.raise_last_exception()web_1  |   file "/usr/local/lib/python3.7/site-packages/django/utils/autoreload.py",line 251,in raise_last_exceptionweb_1  |     six.reraise(*_exception)web_1  |   file "/usr/local/lib/python3.7/site-packages/django/utils/six.py",line 685,in reraiseweb_1  |     raise value.with_traceback(tb)web_1  |   file "/usr/local/lib/python3.7/site-packages/django/utils/autoreload.py",**kwargs)web_1  |   file "/usr/local/lib/python3.7/site-packages/django/__init__.py",line 27,in setupweb_1  |     apps.populate(settings.INSTALLED_APPS)web_1  |   file "/usr/local/lib/python3.7/site-packages/django/apps/registry.py",line 85,in populateweb_1  |     app_config = AppConfig.create(entry)web_1  |   file "/usr/local/lib/python3.7/site-packages/django/apps/config.py",line 94,in createweb_1  |     module = import_module(entry)web_1  |   file "/usr/local/lib/python3.7/importlib/__init__.py",line 127,in import_moduleweb_1  |     return _bootstrap._gcd_import(name[level:],package,level)web_1  |   file "<froZen importlib._bootstrap>",line 1006,in _gcd_importweb_1  |   file "<froZen importlib._bootstrap>",line 983,in _find_and_loadweb_1  |   file "<froZen importlib._bootstrap>",line 967,in _find_and_load_unlockedweb_1  |   file "<froZen importlib._bootstrap>",line 677,in _load_unlockedweb_1  |   file "<froZen importlib._bootstrap_external>",line 728,in exec_moduleweb_1  |   file "<froZen importlib._bootstrap>",line 219,in _call_with_frames_removedweb_1  |   file "/usr/local/lib/python3.7/site-packages/django/contrib/admin/__init__.py",line 4,in <module>web_1  |     from django.contrib.admin.filters import (web_1  |   file "/usr/local/lib/python3.7/site-packages/django/contrib/admin/filters.py",line 10,in <module>web_1  |     from django.contrib.admin.options import IncorrectLookupParametersweb_1  |   file "/usr/local/lib/python3.7/site-packages/django/contrib/admin/options.py",line 13,in <module>web_1  |     from django.contrib.admin import helpers,Widgetsweb_1  |   file "/usr/local/lib/python3.7/site-packages/django/contrib/admin/Widgets.py",line 152web_1  |     '%s=%s' % (k,v) for k,v in params.items(),web_1  |     ^web_1  | SyntaxError: Generator Expression must be parenthesized^CGracefully stopPing... (press Ctrl+C again to force)StopPing root_web_1 ... StopPing root_db_1  ... Killing root_web_1  ... doneKilling root_db_1   ... done

Dockerfile

FROM python:3 ENV PYTHONUNBUFFERED 1 RUN mkdir /code workdir /code ADD requirements.txt /code/ RUN pip install -r requirements.txt ADD . /code/

泊坞窗,compose.yml

version: '3'services:  db:    image: postgres  web:    build: .    command: python3 manage.py runserver 0.0.0.0:8000    volumes:      - .:/code    ports:      - "8000:8000"    depends_on:      - db
解决方法 第一个sudo服务码头重启

在你的Dockerfile中

FROM python:3.6

然后sudo docker-compose up –build

要么sudo docker-compose运行web python manage.py migrate和sudo docker-compose up –build

总结

以上是内存溢出为你收集整理的django – 使用python 3.7的Docker错误:生成器表达式必须括起来全部内容,希望文章能够帮你解决django – 使用python 3.7的Docker错误:生成器表达式必须括起来所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1194398.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-03
下一篇 2022-06-03

发表评论

登录后才能评论

评论列表(0条)

保存