docker-compose运行pserve时的DistributionNotFound
我试图用docker-compose来运行我的简单金字塔应用程序,下面是我的docker文件:
Dockerfile :
FROM python:2.7-onbuild RUN pip install --no-cache-dir -r requirements_dev.txt
泊坞窗,compose.yml
db: image: mysql:5.6 web: build: . command: pserve development.ini --reload volumes: - .:/usr/src/app ports: - "6543:6543" links: - db:db
当我运行pkg_resources.DistributionNotFound: The 'tenders' distribution was not found and is required by the application
docker-compose up
我得到了pkg_resources.DistributionNotFound: The 'tenders' distribution was not found and is required by the application
,这很奇怪,因为我的应用程序应该已经通过pip install -e .
命令。
事情变得越来越怪异:
docker-compose run web bash root@2323b6b2f3ca:/tenders# pip freeze | grep tenders # no results root@2323b6b2f3ca:/tenders# pip install -e . Obtaining file:///tenders # Skippping most of the outup for more readability Installing collected packages: tenders Running setup.py develop for tenders Successfully installed tenders root@2323b6b2f3ca:/tenders# pip freeze | grep tenders -e git+git@bitbucket.org:xxx/tenders.git@342a8f9101a3e06fa04d71f4eef81b461476d3a5#egg=tenders-master
现在,当我启动pserve development.ini --reload
它工作得很好。
我在做什么错了,我怎样才能使用pip install -e .
自动安装我的包装tenders
pip install -e .
(或任何其他命令)?
我有同样的问题。 Docker卷装入时会发生这种情况。
在您的Dockerfile中,您使用pip install -e .
安装应用程序pip install -e .
,在当前目录(在图像中)中创build.egg-info目录。 但后来,当您使用docker卷来replace容器源目录时,您的主机文件系统中没有这个.egg-info目录。
我解决这个问题的方法是在我的主机文件系统中创build了一个virtualenv,我运行了python setup.py develop
,但是我想你可以运行pip install -e .
。 它创build了.egg-info目录,以便在从容器运行pserve
时存在该目录。 这个virtualenv可能会被删除。
我真的不知道这是最好的解决scheme,但至less现在你知道问题的原因了。