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
Python/Pandas: Convert Month Int to Month Name
How to Get a Value from a Cell of a Dataframe
Python: How to Add Single Quotes to a Long List
Python Does Not Match Format '%Y-%M-%Dt%H:%M:%S%Z.%F'
How to Extract Integer or Float from String
Python Print First N Lines of String
How to Compile Multiple Python Files into Single .Exe File Using Pyinstaller
Formatting Datetime Xlabels in Matplotlib (Pandas Df.Plot() Method)
Expression to Remove Url Links from Twitter Tweet
How to Embed Matplotlib Graph in Django Webpage
How to Find Duplicate Values in a List and Merge Them
Find Out the Percentage of Missing Values in Each Column in the Given Dataset
Python3: How to Print Out User Input String and Print It Out Separated by a Comma
Return the First Key in Dictionary - Python 3
Python Strip Hyphen from Block of String
How to Print Numbers in a List That Are Less Than a Variable. Python
How to Find Last Occurence Index Matching a Certain Value in a Pandas Series