加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

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

发布时间:2020-12-20 12:14:36 所属栏目:Python 来源:网络整理
导读:嗨,我正在关注…的 django教程( Quickstart: Compose and Django),我有这个错误: SyntaxError: Generator expression must be parenthesized 追溯 root@localhost:~# docker-compose upStarting root_db_1 ... doneStarting root_web_1 ... doneAttaching t
嗨,我正在关注…的 django教程( Quickstart: Compose and Django),我有这个错误:

SyntaxError: Generator expression must be parenthesized

追溯

root@localhost:~# docker-compose up
Starting root_db_1 ... done
Starting root_web_1 ... done
Attaching to root_db_1,root_web_1
db_1   | 2018-09-09 00:09:10.440 UTC [1] LOG:  listening on IPv4 address "0.0.0.0",port 5432
db_1   | 2018-09-09 00:09:10.440 UTC [1] LOG:  listening on IPv6 address "::",port 5432
db_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 UTC
db_1   | 2018-09-09 00:09:10.597 UTC [21] LOG:  database system was not properly shut down; automatic recovery in progress
db_1   | 2018-09-09 00:09:10.599 UTC [21] LOG:  redo starts at 0/1633C88
db_1   | 2018-09-09 00:09:10.599 UTC [21] LOG:  invalid record length at 0/1633CC0: wanted 24,got 0
db_1   | 2018-09-09 00:09:10.599 UTC [21] LOG:  redo done at 0/1633C88
db_1   | 2018-09-09 00:09:10.632 UTC [1] LOG:  database system is ready to accept connections
web_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 wrapper
web_1  |     fn(*args,**kwargs)
web_1  |   File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/runserver.py",line 116,in inner_run
web_1  |     autoreload.raise_last_exception()
web_1  |   File "/usr/local/lib/python3.7/site-packages/django/utils/autoreload.py",line 251,in raise_last_exception
web_1  |     six.reraise(*_exception)
web_1  |   File "/usr/local/lib/python3.7/site-packages/django/utils/six.py",line 685,in reraise
web_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 setup
web_1  |     apps.populate(settings.INSTALLED_APPS)
web_1  |   File "/usr/local/lib/python3.7/site-packages/django/apps/registry.py",line 85,in populate
web_1  |     app_config = AppConfig.create(entry)
web_1  |   File "/usr/local/lib/python3.7/site-packages/django/apps/config.py",line 94,in create
web_1  |     module = import_module(entry)
web_1  |   File "/usr/local/lib/python3.7/importlib/__init__.py",line 127,in import_module
web_1  |     return _bootstrap._gcd_import(name[level:],package,level)
web_1  |   File "<frozen importlib._bootstrap>",line 1006,in _gcd_import
web_1  |   File "<frozen importlib._bootstrap>",line 983,in _find_and_load
web_1  |   File "<frozen importlib._bootstrap>",line 967,in _find_and_load_unlocked
web_1  |   File "<frozen importlib._bootstrap>",line 677,in _load_unlocked
web_1  |   File "<frozen importlib._bootstrap_external>",line 728,in exec_module
web_1  |   File "<frozen importlib._bootstrap>",line 219,in _call_with_frames_removed
web_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 IncorrectLookupParameters
web_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,widgets
web_1  |   File "/usr/local/lib/python3.7/site-packages/django/contrib/admin/widgets.py",line 152
web_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  ... done
Killing 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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读