ImportError: No module named apps from django-grappelli - django

I was working on one django project on my old machine and it was working fine.
Now I am trying to shift my django development environment to new machine (Linux). As a dependency in my project, I am using django-grappelli in it.
I have installed the django-grappelli using following command
sudo pip install --upgrade django-grappelli
It is installed successfully, but now I am trying to run my application and it is giving me following error.
File "/usr/local/lib/python2.7/dist-packages/grappelli/dashboard/__init__.py", line 1, in <module>
from grappelli.dashboard.dashboards import * File "/usr/local/lib/python2.7/dist-packages/grappelli/dashboard/dashboards.py", line 13, in <module>
from grappelli.dashboard import modules File "/usr/local/lib/python2.7/dist-packages/grappelli/dashboard/modules.py", line 11, in <module>
from django.apps import apps as django_apps ImportError: No module named apps
I have search around and tried many suggestions, but didn't work. If I am uninstalling the grappelli, It is goving me error for
No module named grappelli
Can anyone suggest where am I doing mistake?
Django version is 1.6

I have tried different things based on my older setup in which all is working fine.
Downgrading the grappelli to version 2.5.3 worked form me. It was not working with 2.6.1 (latest varsion). Not very sure about if is this the issue with 2.6.1 grappelli version or is there any prerequisite for it.
I have uninstalled the 2.6.1 and installed 2.5.3 grappelli, and it resolved my issue.

The problem isn't with grapelli, that is being installed correctly. The problem is that django 1.6 does not have the apps folder, or at least your instance of django 1.6 and my instance of django 1.6 (I looked into 1.6.5) both don't have the apps folder.
I'm not sure what you're using the apps namespace for, but that's where the problem is.

django-grappelli 2.6 is not compatible with Django 1.6.
The apps folder was created in 1.7 alpha stage in this commit:
https://github.com/django/django/commit/860c2c8bc5c77194c41464655851379bf512a052

Related

django-admin --version displays error in virtual environment

After installing Django version 1.9 in a virtual environment using the following command in Windows:
django-admin --version
I receive a long error, ending with:
File "C:\Users\DELL\env\Lib\site-packages\django\db\models\sql\query.py", line 11, in <module>
from collections import Counter, Iterator, Mapping, OrderedDict
ImportError: cannot import name 'Iterator' from 'collections' (C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\collections\__init__.py)
Python is installed, and the virtual environment was activated.
Django was installed using pip install django==1.9
What should I do to run the command django-admin --version?
Django 1.9 requires Python 2.7, 3.4, or 3.5..make sure you have installed python version from one of these..
(I have copied the answer that I got)
You are using a very old version of Django and, as a result, your Python is incompatible with it. Django is trying to import Iterator from a Python module, but it was moved long ago from collections to collections.abc and that is why it gives you the ImportError.
You can either upgrade you Django to the current version or change your Python to below version 3.3

removing model fields from third party apps in django

I had installed dj-places app into my django project to have PlacesField() to autocomplete the locations field in my model. It did not work as expected. I uninstalled the app and changed the field to models.CharField().
The problem is whenever I am trying to make further migrations I am getting an error.
posts\migrations\0007_auto_20200709_1445.py", line 4, in <module>
import places.fields
ModuleNotFoundError: No module named 'places'
How can I resolve this?
If you pip install the app then you can run makemigrations and migrate then pip uninstall the app again. This should work.

ImportError: No module named 'django' despite having it installed running apache2 server

I know that many have posted similar question however I tried most solution without success.
I'm trying to host a webpage with apache2 and django in python3.
In the error log I found ImportError: No module named 'django' when accessing the wsgi.pyfile, where I also added import sys, sys.version to confirm which python version is used and from the error log I can see that I'm running following python version 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609].
When I run python3.5 I see that I uses the same python version and here I can run import django without any error!
EDIT: I checked django.__file__and saw that it was located in /home/USERNAME/.local/lib/python3.5/site-packages/django/init.py and that path /home/USERNAME/.local/lib/python3.5/site-packages wasn't in the sys.path that tried to run django. But adding it with sys.path.append(path) didn't help :(
Any thoughts what I might have messed up?
If you have Setup the whole configuration in VirtualEnv then , i suggest you to activate it by,
source /location to /env/bin activate
pip3 install django=version_id
or pip install django=version id
if you want to pass version id then its good or it will install the latest django from your repo.
Now test Django Version there.
Hope you will no get the error.
Location - means the path where env will be located in project directory, if you have followed the standard installation process of django or else you don't need, and version id- vesion of django framework.
I finally understood how to solve it! first I had to run pip3 uninstall django then run sudo pip3 install django.

Django error for psycopg2 ImportError: DLL load failed

Hi I am getting this error while I am trying to run syncdb in my virtual environment.
If I copy psycopg2 folder to my project folder (where I have my manage.py and settings.py) then this error disappears. But I still get this error when the code is pushed to heroku.
I have referred to many online materials but wasn't very lucky.
File "c:\Users\mayayadav\anteus\venv\lib\site-packages\psycopg2-2.4.5-py2.7-wi
n32.egg\psycopg2\__init__.py", line 67, in <module>
from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: DLL load failed: The specified module could not be found. (venv)
I had the same problem on Windows, The way i get it working was to install psycopg2 from:
http://www.stickpeople.com/projects/python/win-psycopg/
And doing it this way it's recomended here http://initd.org/psycopg/install/
In the case, where the install binaries are not up to date (as it happened today: latest Python is 3.4 and PostgresSQL - 9.3, while latest avaiable are 3.3 and 9.2.6 respectively), it is enough to add the PostgresSQL binary path (e.g. C:\Program Files\PostgreSQL\9.3\bin) to the path variable.
Note: you need to restart your command line to get it working.
2019 Update
I encountered the same issue with Python 3.8 and psycopg2 2.8.3 and 2.8.4. Apparently psycopg2 doesn't work with Python 3.8 yet (understandably, since 3.8 released very recently). The fix for me was to go back to using Python 3.7.
It's so old problem... I ran into a problem with PyCharm and virtualenv, PyCharm have problem with pip install psycopg2. I copied _psycopg.cp38-win_amd64.pyd from global python to \venv\Lib\site-packages\psycopg2. And all done.

importerror: No module named django

I installed python 2.6 alongside my mac's 2.5.2 version. As soon as I did, python2.6 manage.py runserver failed because it couldn't find django.core.management.
From a shell, import django returns importerror: No module named django.
Why?
Did you reinstall Django?
This happens when I install side by side versions of Python on Gentoo. Whenever I install a new version, I have to either reinstall the new ones or make a symlink to the old site-packages.
Because each installation of Python uses its own directory to store libraries. On a Mac, they are in /Library/Python/2.x/site-packages/. Presumably you originally installed Django in the 2.5 directory, but it isn't yet in the 2.6 one. You can symlink it there if you want to, or reinstall it using the new version.
Add site-packages to PYTHONPATH:
export PYTHONPATH="/home/jerome/bin/django-1.1/lib/python2.6/site-packages:$PYTHONPATH"
Worked on Ubuntu, with a python/django virtual environment using virtualenv and pip.
Source: http://benfsayer.com/importerror-no-module-named-django-core-management/
I use Bitnami's Django installer, and this happened for me when I wasn't in their custom shell, which I believe sets related python path environment variables. I ran ./use_djangostack in the root of the Bitnami package and then was successful running the server again.