python - 在 docker 容器上构建图像以运行自己的 Django 应用程序

标签 python django docker

我正在尝试构建一个图像以在 Docker 容器中运行,并使用自己现有的 Django 应用程序执行以下命令

    sudo docker build -t avilaholding/clubmercado ~/Documents/docker/cmimage

但是我用 psycopg2 得到了这个错误

Collecting pathspec==0.3.4 (from -r /srv/clubmercado/requirements.txt (line 23))
  Downloading pathspec-0.3.4.tar.gz
Collecting psycopg2==2.6.1 (from -r /srv/clubmercado/requirements.txt (line 24))
  Downloading psycopg2-2.6.1.tar.gz (371kB)
    Complete output from command python setup.py egg_info:
    running egg_info
    creating pip-egg-info/psycopg2.egg-info
    writing pip-egg-info/psycopg2.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
    writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
    warning: manifest_maker: standard file '-c' not found

    Error: pg_config executable not found.

    Please add the directory containing pg_config to the PATH
    or specify the full executable path with the option:

        python setup.py build_ext --pg-config /path/to/pg_config build ...

    or with the pg_config option in 'setup.cfg'.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-5wxAAo/psycopg2/
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
The command '/bin/sh -c pip install -r $DOCKYARD_SRVPROJ/requirements.txt' returned a non-zero code: 1

我认为这可能是因为它在 python 2.7 上运行,但我希望它在 python 3.5 上运行。我在 Ubuntu 16.04 上安装了这两个版本。

此外,当我执行 pip --version 或者 pip3 --version

会提示安装的版本已经是9.0.1版本

最佳答案

我遇到了同样的问题。我修复了它运行

sudo apt-get install python-dev libpq-dev

关于python - 在 docker 容器上构建图像以运行自己的 Django 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42540732/

相关文章:

python - 使用 Python 使用 Google、Facebook 或 Twitter 帐户登录网站

Python:为列和值设置参数 pypyodbc - executemany

python - Apache/Wsgi - 返回 header 之前脚本超时

python - Django 多重继承 E005

r - 在Sagemaker超时上运行R

Docker 与 nginx 组合不断显示欢迎页面

python - 测试 Memcached 连接

Django 1.4 弃用 ADMIN_MEDIA_PREFIX 但我的项目是使用 Django 1.3 启动的,因此在 Django 1.4 中使用时遇到问题

ruby-on-rails - 尽管一切似乎正确,但乘客仍在生产中运行?

传递给函数的 Python 自由字符串