Unable to Install Psycopg2 (Pip Install Psycopg2)

How to install psycopg2 with pip on Python?

Note: Since a while back, there are binary wheels for Windows in PyPI, so this should no longer be an issue for Windows users. Below are solutions for Linux, Mac users, since lots of them find this post through web searches.



Option 1

Install the psycopg2-binary PyPI package instead, it has Python wheels for Linux and Mac OS.

pip install psycopg2-binary


Option 2

Install the prerequsisites for building the psycopg2 package from source:

Debian/Ubuntu

Python 3

sudo apt install libpq-dev python3-dev

You might need to install python3.8-dev or similar for e.g. Python 3.8.

Python 2

sudo apt install libpq-dev python-dev

If that's not enough, try

sudo apt install build-essential

or

sudo apt install postgresql-server-dev-all

as well before installing psycopg2 again.

CentOS 6

See Banjer's answer

macOS

See nichochar's answer

Building wheel for psycopg2 ... error pip3 install psycopg2?

I solve my problem work for me
basically issue also with python
version I install python version 3.7 by using this command

sudo apt-get install python3.7

then activate environment

source env/bin/activate

Then I install my requirements.txt files by using this command

 python3.7 -m pip install requirements.txt

my this error resolved not show me again
Building wheel for psycopg2 … error pip3 install psycopg2?

then show me

ModuleNotFoundError: No module named 'pandas'
then I install using this way

python3.7 -m pip install pandas

When I run python3.7 manage.py runserver
Then show me error is django-rq

/code/data/.local/lib/python3.7/site-packages/django_rq/queues.py", line 132
def get_queue(name='default', default_timeout=None, async=None,
^

I this so async is reserved word now in python then in my package I replace the name of async to is_async in whole django-rq/queues.py
when I run project again then show me this error

  import xlsxwriter
ModuleNotFoundError: No module named 'xlsxwriter'

Then I fix by this way

 python3.7 -m pip install xlsxwriter         

Then show me one more error

 from bs4 import BeautifulSoup
ModuleNotFoundError: No module named 'bs4'

Then I fixed using this way

python3.7 -m pip install bs4     

Then my project work fine.
I hope my solution is helpful for anyone.
I have require temporarily python3.7 version so I'm not wanted to change their path to python3 .

Can't install psycopg2

Turns out this 3 and a half hour process I've been going through was unecessary. an exe installer of psycopg2 can be downloaded from here



Related Topics



Leave a reply



Submit