No module named 'django' in conda virtualenv - django

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).

Related

Project Can not be created in 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

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

error running python manage.py on ubuntu

Please help, I am fairly new to django.
I am using virtualenv (which has django installed) I have used this command to create a new project
django-admin startproject projectname
and consequently used the code
cd projectname.
But when I run python manage.py
I get this error:
Traceback (most recent call last):
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
ImportError: No module named 'django'
this is how my manage.py file looks like:
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "firstdjango.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
Install virtual environment in your system
sudo apt-get install virtualenv
Create virtual environment
virtualenv envirnment_name
Activate virtual environment by following command
source envirnment_name/bin/activate
Install django in virtual environment
pip install django
And then run your django server
pyhton manage.py runserver
First, make sure that you are working on the virtualenv that you created using workon your_virtual_env.
Second, try the pip freeze > requirements.txt so you can check the installed packages. The file should have a structure like this:
Django == 1.10.2
SomePackage == 1.2.3
SomeOtherPackage == 1.2.3
You can verify that the Django package is installed this way.

Error with virtualenv after having installed python 2.7

I've just installed python 2.7 from source for my Debian Squeeze. But now, when I use virtualenv, for this specific python version, I have this error:
~/ENV$ virtualenv -p /usr/local/bin/python2.7 --no-site-packages --distribute script_prod
Traceback (most recent call last):
File "/usr/bin/virtualenv", line 2, in <module>
import virtualenv
ImportError: No module named virtualenv
How can I fix it?
I've found out that I need to install virtualenv with python2.7 in order to make it works!