203๐
The first thing to do is to install the dependencies.
sudo apt-get build-dep python-psycopg2 sudo apt install python3-psycopg2 # Python 3
After that go inside your virtualenv and use:
pip install psycopg2-binary
These two commands should solve the problem.
43๐
pip install psycopg2-binary
The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use โpip install psycopg2-binaryโ instead. For details see: http://initd.org/psycopg/docs/install.html#binary-install-from-pypi.
- [Django]-Django 1.8 KeyError: 'manager' on relationship
- [Django]-How to resize an ImageField image before saving it in python Django model
- [Django]-Get class name of django model
- [Django]-Django: list all reverse relations of a model
- [Django]-Django admin default filter
- [Django]-Django values_list vs values
6๐
I installed it successfully using these commands:
sudo apt-get install libpq-dev python-dev
pip install psycopg2
- [Django]-Django MEDIA_URL and MEDIA_ROOT
- [Django]-How to save pillow image object to Django ImageField?
- [Django]-Django rest framework change primary key to use a unqiue field
6๐
For macOS Mojave
just run pip install psycopg2-binary
. Works fine for me, python version -> Python 3.7.2
- [Django]-Token Authentication for RESTful API: should the token be periodically changed?
- [Django]-Django database query: How to get object by id?
- [Django]-Allowing RabbitMQ-Server Connections
4๐
first install apt-get install python-setuptools
then try easy_install psycopg2
- [Django]-Django admin: How to display the field marked as "editable=False" in the model?
- [Django]-ValueError: The field admin.LogEntry.user was declared with a lazy reference
- [Django]-Can't compare naive and aware datetime.now() <= challenge.datetime_end
4๐
This is what helped me on Ubuntu if your python installed from Ubuntu installer. I did this after unsuccessfully trying โapt-get installโ and โpip installโ:
In terminal:
sudo synaptic
then in synaptic searchfield write
psycopg2
choose
python-psycopg2
mark it for installation using mouse right-click and push โapplyโ. Of course, if you donโt have installed synaptic, then first do:
sudo apt-get install synaptic
- [Django]-Why is factory_boy superior to using the ORM directly in tests?
- [Django]-Adding to the "constructor" of a django model
- [Django]-What is a django.utils.functional.__proxy__ object and what it helps with?
3๐
I ran into this same issues recently and this code worked.
sudo apt-get install libpq-dev python-dev-is-python3
Then
pip3 install psycopg2
- [Django]-Django return file over HttpResponse โ file is not served correctly
- [Django]-How to query as GROUP BY in Django?
- [Django]-How to save pillow image object to Django ImageField?
2๐
In python 3.4, while in a virtual environment, make sure you have the build dependencies first:
sudo apt-get build-dep python3-psycopg2
Then install it:
pip install psycopg2
- [Django]-Django โ No module named _sqlite3
- [Django]-Django 1.5b1: executing django-admin.py causes "No module named settings" error
- [Django]-Extend base.html problem
2๐
On Alpine Linux (majority of the docker containers) do:
apk add postgresql-dev
Then:
pip install psycopg2-binary
- [Django]-How to add a cancel button to DeleteView in django
- [Django]-Table thumbnail_kvstore doesn't exist
- [Django]-ImportError: Failed to import test module:
1๐
I used the extension after only importing psycopg2:
import psycopg2
...
psycopg2.extensions.AsIs(anap[i])
- [Django]-Stack trace from manage.py runserver not appearing
- [Django]-Timestamp fields in django
- [Django]-What is a "django backend"?
1๐
It seems that you need gcc-4.0
, and it would be helpful to specify your OS type and version.
Maybe this question will help you a bit: Installing GCC to Mac OS X Leopard without installing Xcode
Update
Iโm a Windows user, so I canโt test your setup, but a quick google pointed to some more links:
- [Django]-Django โ accessing the RequestContext from within a custom filter
- [Django]-How can I avoid "Using selector: EpollSelector" log message in Django?
- [Django]-How do I perform HTML decoding/encoding using Python/Django?
1๐
I encountered the No module named psycopg2.extensions
error when trying to run pip2 install psycopg2
on a Mac running Mavericks (10.9). I donโt think my stack trace included a message about gcc, and it also included a hint:
Error: pg_config executable not found.
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'.
I looked for the pg_config
file in my Postgres install and added the folder containing it to my path: /Applications/Postgres.app/Contents/Versions/9.4/bin
. Your path may be different, especially if you have a different version of Postgres installed โ I would just poke around until you find the bin/
folder. After doing this, the installation worked.
- [Django]-Using the reserved word "class" as field name in Django and Django REST Framework
- [Django]-Django: Using F arguments in datetime.timedelta inside a query
- [Django]-Table thumbnail_kvstore doesn't exist
1๐
try this:
sudo pip install -i https://testpypi.python.org/pypi psycopg2==2.7b2
.. this is especially helpful if youโre running into egg error
on aws ec2 instances if you run into gcc error; try this
1. sudo yum install gcc python-setuptools python-devel postgresql-devel
2. sudo su โ
3. sudo pip install psycopg2
- [Django]-How to repeat a "block" in a django template
- [Django]-Where does pip install its packages?
- [Django]-Django models: get list of id
- [Django]-Django rest framework: query parameters in detail_route
- [Django]-Why does DEBUG=False setting make my django Static Files Access fail?
- [Django]-How to update an existing Conda environment with a .yml file
1๐
I had such problem when trying to run python script as a sudo, while psycopg2 was installed via pip3 to my own userโs directory.
I managed to resolve the issue for myself removing pip3 version, and just installing it via apt:
pip3 uninstall psycopg2
sudo apt install python3-psycopg2
- [Django]-How can I enable CORS on Django REST Framework
- [Django]-Django staticfiles not found on Heroku (with whitenoise)
- [Django]-Django.contrib.gis.db.backends.postgis vs django.db.backends.postgresql_psycopg2
1๐
pip3 install django-psycopg2-extension
I know i am late and thereโs lot of answers up here which also solves the problem. But today i also faced this problem and none of this helps me. Then i found the above magical command which solves my problem ๐ . so i am posting this as it might be case for you too.
Happy coding.
- [Django]-How to set and get cookies in Django?
- [Django]-Django-nonrel + Django-registration problem: unexpected keyword argument 'uidb36' when resetting password
- [Django]-Django project models.py versus app models.py
0๐
you can install gcc for macos from https://github.com/kennethreitz/osx-gcc-installer
after instalation of gcc youโll be able to install psycopg with easy_install
or with pip
- [Django]-Django FileField with upload_to determined at runtime
- [Django]-Django-taggit โ how do I display the tags related to each record
- [Django]-Retrieving a Foreign Key value with django-rest-framework serializers
0๐
Check if you have installed psycopg2 if not
sudo apt-get install psycopg2
Install the dependencies.
sudo apt-get build-dep python-psycopg2
These two commands should solve the problem.
- [Django]-Group by Foreign Key and show related items โ Django
- [Django]-Django โ {% csrf_token %} was used in a template, but the context did not provide the value
- [Django]-Django Rest Framework remove csrf
0๐
This error raise because you not install postgres database in you project virtutal environment. you should run one of these command.
from a terminal you can you command for sudo.
sudo apt-get install build-dep python-psycopg2
for pip (pip basically work for python)
pip install psycopg2
or
pip3 install psycopg2-binary
iโm pretty sure it will work for you.
- [Django]-Get the latest record with filter in Django
- [Django]-The QuerySet value for an exact lookup must be limited to one result using slicing. Filter error
- [Django]-Django โ SQL bulk get_or_create possible?
0๐
Below commands worked for me on Mac OS
brew install libpq
pip install psycopg2-binary
- [Django]-Many-To-Many Fields View on Django Admin
- [Django]-Django return file over HttpResponse โ file is not served correctly
- [Django]-Django.db.utils.ProgrammingError: relation already exists
- [Django]-When saving, how can you check if a field has changed?
- [Django]-How about having a SingletonModel in Django?
- [Django]-Django select only rows with duplicate field values