2

我有一个运行 python 3.4 的 django 应用程序,我想使用 Fig 来帮助为我的应用程序组件设置 dockerized 容器。当我运行时,fig up我收到以下错误:

Recreating app_db_1...
Recreating app_search_1...
Creating app_web_1...
Traceback (most recent call last):
  File "/usr/local/Cellar/fig/1.0.1/libexec/bin/fig", line 9, in <module>
    load_entry_point('fig==1.0.1', 'console_scripts', 'fig')()
  File "/usr/local/Cellar/fig/1.0.1/lib/python2.7/site-packages/fig-1.0.1-py2.7.egg/fig/cli/main.py", line 31, in main
  File "/usr/local/Cellar/fig/1.0.1/lib/python2.7/site-packages/fig-1.0.1-py2.7.egg/fig/cli/docopt_command.py", line 21, in sys_dispatch
  File "/usr/local/Cellar/fig/1.0.1/lib/python2.7/site-packages/fig-1.0.1-py2.7.egg/fig/cli/command.py", line 28, in dispatch
  File "/usr/local/Cellar/fig/1.0.1/lib/python2.7/site-packages/fig-1.0.1-py2.7.egg/fig/cli/docopt_command.py", line 24, in dispatch
  File "/usr/local/Cellar/fig/1.0.1/lib/python2.7/site-packages/fig-1.0.1-py2.7.egg/fig/cli/command.py", line 56, in perform_command
  File "/usr/local/Cellar/fig/1.0.1/lib/python2.7/site-packages/fig-1.0.1-py2.7.egg/fig/cli/main.py", line 427, in up
  File "/usr/local/Cellar/fig/1.0.1/lib/python2.7/site-packages/fig-1.0.1-py2.7.egg/fig/project.py", line 174, in up
  File "/usr/local/Cellar/fig/1.0.1/lib/python2.7/site-packages/fig-1.0.1-py2.7.egg/fig/service.py", line 199, in recreate_containers
  File "/usr/local/Cellar/fig/1.0.1/lib/python2.7/site-packages/fig-1.0.1-py2.7.egg/fig/service.py", line 176, in create_container
  File "/usr/local/Cellar/fig/1.0.1/lib/python2.7/site-packages/fig-1.0.1-py2.7.egg/fig/service.py", line 370, in _get_container_create_options
TypeError: unhashable type: 'dict'

这是因为与 Python 3 不兼容吗?即有什么方法可以使用 fig 来帮助构建我的应用程序,还是我不走运?Fig是使用自制软件安装的。

这是我的无花果文件:

db:
    image: kartoza/postgis
web:
    build: .
    command: python manage.py runserver:8000
    volumes:
      - .:/code
    ports:
      - "8000:8000"
    links:
      - db
      - search
    environment:
      - ALLOWED_HOSTS:
      - STRIPE_CLIENT_ID:
      - STRIPE_CLIENT_SECRET:
      - GOOGLE_API_KEY:
search:
    image: dockerfile/elasticsearch
    links:
      - db
4

2 回答 2

6

Turns out the problem was not with the version of Python, but with my fig file.

Fig file should not have dashes in front of environment variables. Corrected fig file is as follows:

db:
    image: kartoza/postgis
web:
    build: .
    command: python manage.py runserver:8000
    volumes:
      - .:/code
    ports:
      - "8000:8000"
    links:
      - db
      - search
    environment:
      ALLOWED_HOSTS:
      STRIPE_CLIENT_ID:
      STRIPE_CLIENT_SECRET:
      GOOGLE_API_KEY:
search:
    image: dockerfile/elasticsearch
    links:
      - db

Fig is a tool written in Python 2.7, and is not available in a Python 3 variety, but that does not mean it is incompatible with Python 3 projects because it is not integrated into the project code. It is a separate tool and is run on its own by python 2.7.

于 2014-11-27T06:16:40.590 回答
0

包名包含一个提示:fig-1.0.1-py2.7.egg

看来您安装了 fig 的 Python 2 版本。尝试pip install fig从 Python 3 环境安装。

于 2014-11-26T13:05:35.543 回答