Every time I am running the application from the Github Repository, I am getting the following error:
Traceback (most recent call last):
File "C:/Users/lenovo-pc/Desktop/Django-Social-Authentication-master/socialauth/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python35\lib\site-packages\django\core\management\__init__.py", line 364, in execute_from_command_line
utility.execute()
File "C:\Python35\lib\site-packages\django\core\management\__init__.py", line 338, in execute
django.setup()
File "C:\Python35\lib\site-packages\django\__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Python35\lib\site-packages\django\apps\registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "C:\Python35\lib\site-packages\django\apps\config.py", line 94, in create
module = import_module(entry)
File "C:\Python35\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'social_django'
I want to know what is social_django all about? I have installed many libraries, but non of then have satisfied this error:
python-social-auth[django]
social-auth-app-django
But nothing happens. Please let me know what I should do.
The Python executable you use to run the application doesn't have social_django installed. You can verify this by running these commands:
python manage.py shell
import social_django
This will give you an error, for the same reason.
You can install it with:
pip install social-auth-app-django
The github project you are referring to, has dependency on package 'social_django'. You can check it here.
So you would need to install 'social_django' that can be installed by
pip install social-auth-app-django
I know, you have mentioned this in the question itself but I am pretty sure that the package is not installed.
Related
I'm working on a Django application and using Fabric for deployment.
When I deployed the apps to staging in Google App Engine using fab testing, I got this error:
Updating service [staging] (this may take several minutes)...failed.
ERROR: (gcloud.app.deploy) Error Response: [9] An internal error occurred while processing task /app-engine-flex/flex_await_healthy/flex_await_healthy>2022-01-01T09:48:30.226Z15496.fj.0: Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/env/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/env/lib/python3.6/site-packages/django/core/management/__init__.py", line 347, in execute
django.setup()
File "/env/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/env/lib/python3.6/site-packages/django/apps/registry.py", line 89, in populate
app_config = AppConfig.create(entry)
File "/env/lib/python3.6/site-packages/django/apps/config.py", line 116, in create
mod = import_module(mod_path)
File "/opt/python3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/env/lib/python3.6/site-packages/django/contrib/postgres/apps.py", line 8, in <module>
from .signals import register_type_handlers
File "/env/lib/python3.6/site-packages/django/contrib/postgres/signals.py", line 3, in <module>
import psycopg2
ModuleNotFoundError: No module named 'psycopg2'
I'm sure the psycopg2 has been installed successfully earlier. Here's the list installed dependencies after checking by pip list:
...
platformdirs 2.4.0
prompt-toolkit 3.0.24
protobuf 3.19.1
psutil 5.5.1
psycopg2 2.8.6
pyasn1 0.4.8
pyasn1-modules 0.2.8
pycairo 1.16.2
...
Anyone can help? Thanks!
Thank you guys for your prompt support. I've managed to resolve it.
Basically during coding I've accidentally commented the psycopg2 line in the requirements.txt. Because earlier all dependencies were installed successfully and everything is running on dev mode properly so I just kept that line excluded out.
But when deploying with Fabric, it will execute the gcloud command (gcloud app deploy) and here's the thing: GCloud will re-run everything (including installing all dependencies all over again). And the psycopg2 wasn't installed (because it's commented out) during that GCloud runtime. That's why GCloud couldn't find it for further executions.
So I've put it back and everything works like a charm. What a stupid move of mine, but it's fantastic to understand how GCloud works on its way
Just add in your requirement.txt to psycopg2=2.9.3
or run the below command manually to your virtual environment
pip install psycopg2
Like the title says, I install crispy forms and it's installed, but when I try to migrate, it says crispy forms it's not installed
(env) C:\Users\Dias\Desktop\Soccer_site\aposta_segura>pip3 install django-crispy-forms
Requirement already satisfied: django-crispy-forms in c:\users\dias\desktop\soccer_site\aposta_segura\env\lib\site-packages (1.9.0)
(env) C:\Users\Dias\Desktop\Soccer_site\aposta_segura>python3 manage.py migrate
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\Users\Dias\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\core\management\__init__.py", lin
e 401, in execute_from_command_line
utility.execute()
File "C:\Users\Dias\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\core\management\__init__.py", lin
e 377, in execute
django.setup()
File "C:\Users\Dias\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\Dias\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\apps\registry.py", line 91, in po
pulate
app_config = AppConfig.create(entry)
File "C:\Users\Dias\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\apps\config.py", line 90, in crea
te
module = import_module(entry)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.752.0_x64__qbz5n2kfra8p0\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'crispy_forms'
(env) C:\Users\Dias\Desktop\Soccer_site\aposta_segura>
If I install using the requirements.txt, the same thing happens, it says all the requirements are installed but crispy forms is not, i tried using "--user" but it doesn't work, don't know if it's a windows thing
As #lain mentioned, it seems that the Requirement is already satisfied in your venv. This could only mean that the interpreter cannot be resolved to the correct venv.
check this in cmd prompt
where python
And
where python3
The output of the first will match to the same directory as your venv.
Most likely its python so just use python manage.py migrate and it should work.
I had a custom user model in my project. I wanted to delete it and return default user model by deleting all tables in my database and deleting migrations. After this, I tried to run python manage.py makemigrations command but it writes:
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/home/irakliy01/Projects/Project/PythonVEnv/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/home/irakliy01/Projects/Project/PythonVEnv/lib/python3.6/site-packages/django/core/management/__init__.py", line 347, in execute
django.setup()
File "/home/irakliy01/Projects/Project/PythonVEnv/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/irakliy01/Projects/Project/PythonVEnv/lib/python3.6/site-packages/django/apps/registry.py", line 89, in populate
app_config = AppConfig.create(entry)
File "/home/irakliy01/Projects/Project/PythonVEnv/lib/python3.6/site-packages/django/apps/config.py", line 116, in create
mod = import_module(mod_path)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/irakliy01/Projects/Project/PythonVEnv/lib/python3.6/site-packages/django/contrib/contenttypes/apps.py", line 9, in <module>
from .management import (
File "/home/irakliy01/Projects/Project/PythonVEnv/lib/python3.6/site-packages/django/contrib/contenttypes/management/__init__.py", line 2, in <module>
from django.db import DEFAULT_DB_ALIAS, migrations, router, transaction
File "/home/irakliy01/Projects/Project/PythonVEnv/lib/python3.6/site-packages/django/db/migrations/__init__.py", line 1, in <module>
from .migration import Migration, swappable_dependency # NOQA
ModuleNotFoundError: No module named 'django.db.migrations.migration'
I have no idea what I did wrong.
Your Django installation seems corrupted. You can reinstall with:
pip3 uninstall Django
pip3 install Django
Usually this happens if you installed Django in your regular operating system's python installation and then later installed a virtualenv copy and tried to run the django server. You need to reinstall Django in your virtualenv, after removing it first if it already exists.
Assuming you are running in the virtual environment, you might have actually deleted the files under /django/db/migrations/ as well. So the error is obvious here. You would need to reinstall django to get the files back for successful migration.
To do this, check the django version
python -m django --version
Then install the same version using following command
pip install --upgrade --force-reinstall Django==3.2.2
I'm trying to run this command on my django project:
python manage.py makemigrations --empty my_app_name
to create a new empty migration.
When I try to run this command in poweshell, I get this message:
PS C:\Travail\workout\workout-backend\workout_rest> python manage.py makemigrations --empty record
Traceback (most recent call last):
File "manage.py", line 17, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\Ben\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\management\__init__.py", line 367, in execute_from_command_line
utility.execute()
File "C:\Users\Ben\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\management\__init__.py", line 341, in execute
django.setup()
File "C:\Users\Ben\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\Ben\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\apps\registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "C:\Users\Ben\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\apps\config.py", line 90, in create
module = import_module(entry)
File "C:\Users\Ben\AppData\Local\Programs\Python\Python35-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'admin_tools'
The error is: ImportError: No module named 'admin_tools'
What am I doing wrong?
I'm on Windows 10 and I'm using VS2017 to developp my Django app.
EDIT:
Something very strange. When I run pip freeze, I get this:
$ pip freeze
astroid==1.4.9
colorama==0.3.7
Django==1.10.3
isort==4.2.5
lazy-object-proxy==1.2.2
mccabe==0.6.1
pylint==1.6.5
six==1.10.0
wrapt==1.10.10
I don't know what are thoses packages. I have no mention of astroid or mccabe in my whole project. Nor in site-package folder, nor in INSTALLED-APP...
Question Solved, it's just a typo in file mysite/polls/models.py. Thanks everyone for the help!
Environment: Ubuntu 14.04 with Python 2.7 and 3.4 preinstalled (default is 2.7) and Django: 1.8.4.
I'm a newbie to Django and trying to follow the Django 1.8 tutorial.
After finished part1, since tutorial was specially designed for python3, not python2, I tried to change Python version, with the following command:
alias python=python3
Now the problem arise: when I run python manage.py createsuperuser, I get the following error:
ImportError: No module named django
I searched on the web for solutions and ended up with this command
python -c "import django; print(django.get_version())"
After executing this line, the error changes to:
ImportError: No module named djangeo.db
I'm stucked here:( I coundn't find a proper solution for this onlne.
There a similar problem on AskUbuntu but it also says hardcoding system path is not a very good idea.
Can anyone help me with this, please?
After installing the Django with pip3, the error message looks like follows:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", line 312, in execute
django.setup()
File "/usr/local/lib/python3.4/dist-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python3.4/dist-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/usr/local/lib/python3.4/dist-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2231, in _gcd_import
File "<frozen importlib._bootstrap>", line 2214, in _find_and_load
File "<frozen importlib._bootstrap>", line 2203, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1448, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/home/julia/mysite/polls/models.py", line 5, in <module>
from djangeo.db import models
ImportError: No module named 'djangeo'
You have not installed Django under python3.
Modules only work for the version of python they were installed for. pip installs modules for python2 by default. To install modules for python3, use pip3
First verify you have pip3 installed:
sudo apt-get install python3-pip
then:
sudo pip3 install django
for future projects, you should consider setting up a virtualenv.