Skip to main content
 首页 » 编程设计

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

2025年02月15日30jiqing9006

我正在尝试构建一个图像以在 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