322π
The release of psycopg2 version 2.9 caused this error as explained in this GitHub issue:
https://github.com/psycopg/psycopg2/issues/1293#issuecomment-862835147
Psycopg 2.9 changed the value passed to tzinfo_factory from an int to a timedelta. Django 2.2 (possibly newer but Iβm on 2.2) has a check for offset == 0 and since timedelta(0) != 0 it goes boom.
One solution is to downgrade psycopg2
(or psycopg2-binary
if you are using the stand-alone package) below 2.9 (e.g. psycopg2>=2.8,<2.9
) in your requirements file.
For instance you can downgrade to 2.8.6
using:
pip install psycopg2==2.8.6
or
pip install psycopg2-binary==2.8.6
If youβre using poetry, you can do poetry add psycopg2@2.8.6
to fix your version to 2.8.6
.
psycopg2 release history
22π
I had the same problem and i fixed it by simply removing this line from my settings.py file
USE_TZ = True
- [Django]-Django β Circular model import issue
- [Django]-Is this the right way to do dependency injection in Django?
- [Django]-What's the difference between select_related and prefetch_related in Django ORM?
15π
I solved this by upgrading Django instead of downgrading psycopg. I donβt know which version solves the issue exactly, but 3.2 certainly does.
The accepted answer is out of date now and you should decide against downgrading if you have the option to upgrade Django instead.
- [Django]-Django 1.3.1 compilemessages. Error: sh: msgfmt: command not found
- [Django]-Django order_by query set, ascending and descending
- [Django]-How to debug in Django, the good way?
11π
This is what I am working to get this all working on Django 2.2.x
(which is not compatible with psycopg2>=2.9.0
:
brew install libpq --build-from-source
brew install openssl
brew link openssl
export LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib -L/opt/homebrew/opt/libpq/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@1.1/include -I/opt/homebrew/opt/libpq/include"
echo 'export PATH="/opt/homebrew/opt/openssl@3/bin:$PATH"' >> ~/.zshrc
brew install postgres
pip install psycopg2==2.8.6
I am on BigSur on a M1 macbook.
- [Django]-Django: Error: You don't have permission to access that port
- [Django]-How to server HTTP/2 Protocol with django
- [Django]-Django-social-auth django-registration and django-profiles β together
2π
For ubuntu users, installing psycopg2==2.8.6, psycopg2-binary==2.8.6 with older versions of django may raise some kind of error. To solve that issue, try,
sudo apt-get install gcc libpq-dev -y
sudo apt-get install python3-dev python3-pip python3-venv python3-wheel -y
pip3 install wheel
This is one kind of solution, other solutions are available at the link below.
https://exerror.com/error-invalid-command-bdist_wheel/#:%7E:text=Just%20use%20below%20command%20pip,command%20python%20setup.py%20bdist_wheel.&text=invalid%20command%20%27bdist_wheel%27-,To%20Solve%20error%3A%20invalid%20command%20%27bdist_wheel%27%20Error%20You%20just,command%20python%20setup.py%20bdist_wheel.?
- [Django]-Why is factory_boy superior to using the ORM directly in tests?
- [Django]-Django-way for building a "News Feed" / "Status update" / "Activity Stream"
- [Django]-Django β No module named _sqlite3
0π
In settings.py
I have changed the value of USE_TZ
= to False
It fixed the problem for me.
[Changing the version of psycobg2
didnβt work for me. Swithing it to older version introduced a new problem of breaking the live development server.]
[It is Windows 11]
- [Django]-Stack trace from manage.py runserver not appearing
- [Django]-How to add url parameters to Django template url tag?
- [Django]-Laravel's dd() equivalent in django
-1π
Ensure you have activated your virtual environment if any case you have deactivated it (please ensure you are within the virtual environment)
to activate your virtual environment use this command: source name of the virtual env/bin/activate
- [Django]-*_set attributes on Django Models
- [Django]-Inline in ModelForm
- [Django]-Django Server Error: port is already in use
-1π
I had this issue..solved by updating django latest version.
INSTALLED_APPS = [
'cart',
]
this line caused me error when lower version (2.2) is used
u can also solve this issue by changing the above line of code to
INSTALLED_APPS = [
'cart.apps.CartConfig',
]
CartConfig
is the class name u can copy and paste from apps.py
of the same app
- [Django]-Gunicorn Connection in Use: ('0.0.0.0', 5000)
- [Django]-Django TemplateDoesNotExist?
- [Django]-How to access Enum types in Django templates
-1π
Author Admin,
ubuntu desktop Ubuntu 22.04.3 LTS
Change in setting.py in your django
USE_TZ = False, youβre indicating that PostgreSQL will handle time zone conversions, so Django wonβt interfere with it.
- [Django]-Convert Django Model object to dict with all of the fields intact
- [Django]-Update all models at once in Django
- [Django]-What is a django.utils.functional.__proxy__ object and what it helps with?