pip安装django-heroku报Error: pg

    技术2025-11-06  21

     pip安装django-heroku时出错信息如下:

    Collecting django-heroku==0.3.1 Downloading https://mirrors.163.com/pypi/packages/59/af/5475a876c5addd5a3494db47d9f7be93cc14d3a7603542b194572791b6c6/django_heroku-0.3.1-py2.py3-none-any.whl Collecting django (from django-heroku==0.3.1) Downloading https://mirrors.163.com/pypi/packages/9d/04/04abb097c84c770180eeebe7ed920ce42f9917ab5ad4de01ff8ed11bc25b/Django-3.0.6-py3-none-any.whl (7.5MB) 100% |################################| 7.5MB 191kB/s Collecting whitenoise (from django-heroku==0.3.1) Downloading https://mirrors.163.com/pypi/packages/ae/25/0c8f08c9d3c93192cd286594f1e87b17bab496fb9082c2a69e17051b91fd/whitenoise-5.0.1-py2.py3-none-any.whl Collecting psycopg2 (from django-heroku==0.3.1) Downloading https://mirrors.163.com/pypi/packages/a8/8f/1c5690eebf148d1d1554fc00ccf9101e134636553dbb75bdfef4f85d7647/psycopg2-2.8.5.tar.gz (380kB) 100% |################################| 389kB 3.5MB/s 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 dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt' Error: pg_config executable not found. pg_config is required to build psycopg2 from source. 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'. If you prefer to avoid building psycopg2 from source, please install the PyPI 'psycopg2-binary' package instead. For further information please check the 'doc/src/install.rst' file (also at <https://www.psycopg.org/docs/install.html>). ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-n6fpjkgb/psycopg2/

    这是由于安装psycopg2出现了问题,可以安装psycopg2-binary代替psycopg2

    解决方法:

    先安装django-heroku的依赖:

    pip install django  pip install whitenoise

    安装psycopg2-binary:

    pip install psycopg2-binary

    最后无依赖安装django-heroku

    pip install --no-dependencies django-heroku

     

    Processed: 0.016, SQL: 9