I have installed psycopg2-binary 2.9.1(pip install psycopg2-binary) in virtualenv, but when I execute python manage.py migrate, that appears "django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No module named 'psycopg2'", and python console also can't import psycopg2. how to fix the problem?
I have fixed my problem by use python3 manage.py migrate.
Related
Hi im trying to run a venv for my project. Everythin goes well install requirments and creating a my venv. The problem is that when i try to make a manage.py migrate i get this error. Ive looked everywhere and i got python version 3.8 installed. Pathlib is part of the package from python 3.4.
I use Windows and python 3.8 with Django version 3.0.12- My project is based on a cockiecutter and i dont want to update to the latest version om django.
Does anone know what the problem is and how it can be solved?
manage.py migrate
Traceback (most recent call last):
File "E:\Dev\Fooders\fooders\manage.py", line 4, in <module>
from pathlib import Path
ImportError: No module named pathlib
Try:
python manage.py migrate
# or if it does not work
python3 manage.py migrate
I am deploying on heroku a website but I am experiencing some issue.
My project is called mysite-project.
I did the following:
1) Create a Procfile containing:
web: gunicorn mysite-project.wsgi
at the base root of my project (same level where manage.py is).
2) app/settings.py
import django_heroku at the top
django_heroku.settings(locals()) at the bottom of settings.py
3)
pip install gunicorn
pip install django-heroku
pip freeze > requirements.txt
4) If I run python manage.py runserver I get:
ModuleNotFoundError: No module named 'django_heroku'
There was a problem with:
pip install django-heroku
It was not fully installed because thee was a problem with psycopg2 that was not installed.
To install psycopg2, run:
pip install psycopg2
Then you can run pip install django-heroku and the error disappeared
I had the same problem as well. I have psycopg2 installed. (for postgres)
Installing 'psycopg2- binary' solved my problem.
For me, the error was due to adding django-heroku to installed apps in settings.py..,removing it solved the issue.
I am running simple python manage.py runserver and getting this error :
File "/usr/local/lib/python3.6/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'
I had tried everything like installing sqlite3,sqlite-devel but nothing works.
Try to make a new virtual environment with virtualenv, conda or any other way you know and then activate your virtualenv, install any package you need inside that to avoid versions conflict problems. Now you can run the app.
Hope this works
I have installed python-social-auth==0.3.6. Then I migrated and got an error:
from social_django.models import AbstractUserSocialAuth, UserSocialAuth, Nonce, Association, Code, DjangoStorage
ImportError: No module named 'social_django'
[UPDATE]: What worked for me was this:
In a clean virtualenv I pip install python-social-auth[django]
I included 'django_social', in my INSTALLED_APPS
I run migrations, ./manage.py migrate
You need to install python-social-auth[django]:
pip install python-social-auth[django]
And then add 'social.apps.django_app.default' to your INSTALLED_APPS.
Then don't forget to run the migrations: ./manage.py migrate
I resolve with
pip install django-rest-framework-social-oauth2==1.0.4 social-auth-core==0.2.1 python-social-auth==0.2.21 django-oauth-toolkit==0.10.0
I have installed Django after activating my virtualenv but still I am getting following error
from django.core.management import execute_from_command_line
ImportError: No module named django.core.management
If you already activated your virtualenv (source /path/bin/activate) then check if you have installed Django.
pip install django
With next command you can see if Django was installed.
pip freeze | grep django
Another thing that you can try is to remove first line (#!/usr/bin/env python) in the manage.py file.
You should check if django is installed
Activate your environment, then run the following command to see which version is installed :
python -c "import django; print(django.get_version())"
I am using virtual environment so I added this line in manage.py:
sys.path.append('./myvenv/lib/python3.5/site-packages')
in which myvenv is the name of my virtual environment and version of my installed Python is 3.5.
This solved my issued.
I found that I had Python 3.4 and 2.7 installed concurrently, and the pip install django==1.7 command automagically decided the Python 3.4 /dist-packages was where it should live. I CD'd over to the Python 2.7 directory and re-piped it... and all is well.
sudo pip install django --upgrade
worked for me, i am not having virutal environment by the way.
I had the same problem when I was running Django from inside a virtual environment and then using another terminal window ran the command
python manage.py shell without first switching to the venv.
The problem was resolved after I switched back.
I found that I could import the django module from the python interpreter, but django-admin.py could not import it when run from the command line.
I confirmed that I was using the python interpreter in my virtual environment.
I was using a 64-bit version of python. Uninstalling, and installing the 32-bit version, then re-creating my venv solved this for me.
If you're using virtualenv, you can add it to your path using sys.path.append('./myvenv/lib/python3.5/site-packages').
Try closing and opening the terminal again. That worked for me too.