Project Can not be created in Django - django

Traceback (most recent call last):
File "/usr/bin/django-admin", line 2, in
from django.core import management
ModuleNotFoundError: No module named 'django'

Did you pip install django?
python -m pip install Django

Related

Can'not launch django installed inside docker

I am using Docker to launch my app which imports django. I want to do it inside my git repository.
My Dockerfile looks like
FROM python:3
WORKDIR /configurator
CMD virtualenv -p python3.8 venv
CMD . venv/bin/activate
CMD pip install -U setuptools pip
CMD pip install django
COPY . /configurator/
CMD cd cconfigurator/
ENTRYPOINT /configurator/cconfigurator/manage.py runserver 8000
And I see an error:
docker run configurator
Traceback (most recent call last):
File "/configurator/cconfigurator/manage.py", line 10, in main
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/configurator/cconfigurator/manage.py", line 21, in <module>
main()
File "/configurator/cconfigurator/manage.py", line 12, in main
raise ImportError(
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
What am I doing wrong?

After installing spyder django is not working

I installed spyder on my ubuntu system From which django is not working. The error it is showing when i ran the server the error showing is is
Traceback (most recent call last):
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 14, in <module>
import django
ModuleNotFoundError: No module named 'django'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 17, in <module>
"Couldn't import Django. Are you sure it's installed and "
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
I need both spyder for OpenCV and also Django. can anyone help
It is working after doing
python3 -m pip install django
thank u mr sahil
The error means that the Django is missing from your system, if you have installed the dependencies in your virtualenv you will need to activate that, or you can just do
pip install django --user
If you have a virtualenv do this,
Linux
source path/to/venv/bin/activate
Windows
path/to/venv/bin/activate
First create a virtual environment, using the following command
python3 -m virtualenv venv
If you get an error saying something similar to this, Virtualenv module not found, you will need to install virtualenv using pip by the following command.
pip3 install virtualenv
Then use the aforementioned command to create the virtual environment.
To activate it just use
source venv/bin/activate
This will activate the virtual environment. Now install Django on it.
pip install django
You don't need to specify a pip version (say pip3) because the virtual environment is created in python3 so pip defaults to pip3 itself.
Now finally run your server
python manage.py runserver localhost:8080

No module named 'django' in conda virtualenv

I hadnt any python installed globally,just miniconda. Then created a virtualenv(conda) and installed django there. Now when I do "django-admin.py startproject projectname" (anaconda prompt,under created virtualenv) first it asked how to open that file & I set it to default python of miniconda ("C:\Users\1\Miniconda3\python.exe").Then it shows:
Traceback (most recent call last):
File "C:\Users\1\Miniconda3\envs\Work_manager\Scripts\django-admin.py", line 2, in <module>
from django.core import management
ModuleNotFoundError: No module named 'django'
sys.path of that virtualenv:
['', 'C:\\Users\\1\\Miniconda3\\envs\\Work_manager\\python36.zip',
'C:\\Users\\1\\Miniconda3\\envs\\Work_manager\\DLLs',
'C:\\Users\\1\\Miniconda3\\envs\\Work_manager\\lib',
'C:\\Users\\1\\Miniconda3\\envs\\Work_manager',
'C:\\Users\\1\\Miniconda3\\envs\\Work_manager\\lib\\site-packages']
django-admin.py is located at "C:\Users\1\Miniconda3\envs\Work_manager\Scripts" &
its shebang is "#!C:/Users/1/Miniconda3/envs/Work_manager\python.exe".
Im using windows 10(x64).

Import Error: No Module named ldap, issues with python-ldap module installation on mac os Serira, python 2.7

Running a simple standalone python script on mac os Sierra. I am getting the following error:
Traceback (most recent call last):
File "user_exists.py", line 4, in <module>
import ldap
ImportError: No module named ldap
I went and tried installing using pip the module, I get the following output:
$sudo -H pip install
Requirement already satisfied: python-ldap in /usr/local /bin/python_ldap-2.4.28-py2.7-macosx-10.12-intel.egg
Requirement already satisfied: setuptools in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from python-ldap)
I tried testing:
$ python -c "import ldap"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named ldap
Please suggest whats the best approach to solve this issue?

Can't import a module in python 2.7 even though pip says it is installed

I've read the many posts on SO regarding using Pillow or Image instead of PIL but I'm still having trouble with this module.
I'm running this on my MBP on 10.9.5.
I used pip to install image 1.5.5 and Pillow 3.4.2. However, when I go to import the module in my script, it keeps saying there's no module of that name.
first.last#localhost:/usr/local/bin> pip freeze | grep Pillow
Pillow==3.4.2
first.last#localhost:/usr/local/bin> pip freeze | grep image
image==1.5.5
first.last#localhost:/usr/local/bin> which pip
/usr/local/bin/pip
first.last#localhost:/usr/local/bin> which python
/usr/local/bin/python
Python 2.7.10 (v2.7.10:15c95b7d81dc, May 23 2015, 09:33:12)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import image
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named image
>>> import PIL
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named PIL
>>> import Pillow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named Pillow
>>> import pillow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pillow
I checked /Library/Python/2.7/site-packages and it doesn't seem like the .py files are there for pillow or image, even though pip freeze showed that image and Pillow are both installed.
This is the contents of pip is this. Not sure if it gives any clues to why pip thinks the modules are installed but python says it can't find it.
#!/usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
# EASY-INSTALL-ENTRY-SCRIPT: 'pip==9.0.1','console_scripts','pip'
__requires__ = 'pip==9.0.1'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('pip==9.0.1', 'console_scripts', 'pip')()
)
From what I showed in my setup/environment, can anyone point me in a general direction to start fixing this problem? Is any additional information needed to debug this some more?
Since you are working outside of a virtualenv, the user site should be enabled. Use the following commands to find the installed location of image and/or pillow:
pip show -f image | grep Location
pip show -f pillow | grep Location
What you probably want to see is something like:
Location: /Users/<your_username>/.local/lib/python2.7/site-packages
If it's not installing there, then uninstall and pip install again with the --user flag.
Then use the following command to make sure that the results of above will be found in your path:
python -m site
What you want to see in the output is something like
sys.path = [
...
]
USER_BASE: '/Users/<your_username>/.local' (exists)
USER_SITE: '/Users/<your_username>/.local/lib/python2.7/site-packages' (exists)
ENABLE_USER_SITE: True
If the installed location is in your user site, and your user site is enabled, then the import will work.