IT

서버 측 확장을 빌드하려면 postgresql-server-dev-XY를 설치하고 클라이언트 측 애플리케이션을 빌드하려면 libpq-dev를 설치해야합니다.

lottoking 2020. 5. 12. 08:16
반응형

서버 측 확장을 빌드하려면 postgresql-server-dev-XY를 설치하고 클라이언트 측 애플리케이션을 빌드하려면 libpq-dev를 설치해야합니다.


virtualenv로 Django 프로젝트를 작업 중이며 로컬 postgres 데이터베이스에 연결하고 있습니다. 프로젝트를 실행하면

ImportError: No module named psycopg2.extensions

그런 다음이 명령을 사용하여 설치

pip install psycopg2

그런 다음 설치 중에 다음 오류가 발생합니다.

Downloading/unpacking psycopg2==2.4.4
  Downloading psycopg2-2.4.4.tar.gz (648kB): 648kB downloaded
  Running setup.py (path:/home/muhammadtaqi/Projects/MyProjects/OnlineElectionCampaign/venv/build/psycopg2/setup.py) egg_info for package psycopg2

    Error: You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.

    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: You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.



----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /home/muhammadtaqi/Projects/MyProjects/OnlineElectionCampaign/venv/build/psycopg2
Storing debug log for failure in /home/muhammadtaqi/.pip/pip.log

다음 명령을 사용하면 오류가 해결됩니다.

sudo apt-get install postgresql

다음 발사 :

sudo apt-get install python-psycopg2

그리고 마침내:

sudo apt-get install libpq-dev

터미널에서 루트 로이 명령을 실행하면 문제가 해결됩니다.

sudo apt-get install -y postgis postgresql-9.3-postgis-2.1
pip install psycopg2

또는

sudo apt-get install libpq-dev python-dev
pip install psycopg2


나를 위해이 간단한 명령으로 문제를 해결했습니다.

sudo apt-get install postgresql postgresql-contrib libpq-dev python-dev

그런 다음 할 수 있습니다 :

 pip install psycopg2

그냥 libpq-dev를 설치하십시오

$ sudo apt-get install libpq-dev

그들은 psycopg2의 포장을 변경했습니다. 이진 버전을 설치하면이 문제가 해결되었습니다. 바이너리를 직접 컴파일하려는 경우 위의 답변은 여전히 ​​유효합니다.

http://initd.org/psycopg/docs/news.html#what-s-new-in-psycopg-2-8을 참조하십시오 .

Binary packages no longer installed by default. The ‘psycopg2-binary’ package must be used explicitly.

And http://initd.org/psycopg/docs/install.html#binary-install-from-pypi

So if you don't need to compile your own binary, use:

pip install psycopg2-binary

For Python 3, I did:

sudo apt install python3-dev postgresql postgresql-contrib python3-psycopg2 libpq-dev

and then I was able to do:

pip3 install psycopg2

You must setup postgresql-server-dev-X.Y, where X.Y. your's servers version, and it will install libpq-dev and other servers variables at modules for server side developing. In my case it was

apt-get install postgresql-server-dev-9.5

Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: libmysqlclient18 mysql-common Use 'apt-get autoremove' to remove them. The following extra packages will be installed:
libpq-dev Suggested packages: postgresql-doc-10 The following NEW packages will be installed: libpq-dev postgresql-server-dev-9.5

In your's case

sudo apt-get install postgresql-server-dev-X.Y
sudo apt-get install python-psycopg2

I was using a virtual environment on Ubuntu 18.04, and since I only wanted to install it as a client, I only had to do:

sudo apt install libpq-dev
pip install psycopg2

And installed without problems. Of course, you can use the binary as other answers said, but I preferred this solution since it was stated in a requirements.txt file.


If you're working from Linux (and possibly other systems but i can't speak from experience) you will need to make sure to be quite exact about what version of python your running when installing the dev package.

When I used the command

sudo apt-get install python3-dev

I still ran into the some error when trying to run

pip install psycopg2

As I am running python 3.7 I needed to use the command

sudo apt-get install python3.7-dev

Obviously if your on version 3.5 you would change that 7 to a 5.

참고URL : https://stackoverflow.com/questions/28253681/you-need-to-install-postgresql-server-dev-x-y-for-building-a-server-side-extensi

반응형