Cannot Install or Failed Installation Psycopg Under PIP Python

Halo sobat developer, disini saya hanya ingin berbagi cara kepada kalian ketika kalian mengalami error install package psycopg2. Disini saya menggunakan Linux Mint dan dalam virtualenv projek maka dari itu installasi menggunakan pip package.

Anehnya ketika kalian sudah mengaktifkan virtualenv lalu kalian menginstall paket dengan menggunakan pip maka yang terjadi adalah

Requirement already satisfied: django in /home/mhafid/Workspace/wartek/lib/python3.6/site-packages (1.11.15)
Collecting psycopg2
Using cached https://files.pythonhosted.org/packages/5c/1c/6997288da181277a0c29bc39a5f9143ff20b8c99f2a7d059cfb55163e165/psycopg2-2.8.3.tar.gz
ERROR: Command errored out with exit status 1:
command: /home/mhafid/Workspace/wartek/bin/python3 -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘”‘”‘/tmp/pip-install-mc97vqdo/psycopg2/setup.py'”‘”‘; file='”‘”‘/tmp/pip-install-mc97vqdo/psycopg2/setup.py'”‘”‘;f=getattr(tokenize, ‘”‘”‘open'”‘”‘, open)(file);code=f.read().replace(‘”‘”‘\r\n'”‘”‘, ‘”‘”‘\n'”‘”‘);f.close();exec(compile(code, file, ‘”‘”‘exec'”‘”‘))’ egg_info –egg-base pip-egg-info
cwd: /tmp/pip-install-mc97vqdo/psycopg2/
Complete output (7 lines):
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: b’You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.\n’
—————————————-
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output

Intinya error, mau install psycopy atau postgresPool sama saja, cara nya agar kalian bisa menginstall psycopg adalah

Jika kalian menginstall 2 versi python 2 dan versi 3, kalian lakukan installasi keduanya, jika kalian hanya menginstall 1 jenis versi python maka hanya satu saja.

Python 2

sudo apt install libpq-dev python-dev

Python 3

sudo apt install libpq-dev python3-dev

Additional :

sudo apt install build-essential

Jika sudah semuanya dilakukan installasi sekarang saatnya kalian lakukan install psycopg nya, dan saya jamin permasalahan kalian terselesaikan.

Leave a Reply

Your email address will not be published. Required fields are marked *