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
Related
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?
I'm trying to create a new environment and install various 3rd party packages on an Ubuntu machine. After having to install condo (for a matplotlib installation) and gdal, the pip function no longer works. Instead I receive:
Traceback (most recent call last):
File "/media/imagery/ENVIRONMENTS/Project_1/bin/pip", line 7, in <module>
from pip._internal import main
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 14, in <module>
from pip.utils import get_installed_distributions, get_prog
File "/usr/lib/python2.7/dist-packages/pip/utils/__init__.py", line 30, in <module>
from pip._vendor.retrying import retry
ImportError: No module named retrying
I've called pip both in and outside my environment, and still observe the same issue. Also I've tried a pip install --upgrade pip and still retrieve the same Traceback. Any ideas how to resolve this?
As a cheap workaround, export PYTHONPATH=" " seemed to work for now in order to install other packages, but as soon as I need the gdal package, I have to then set PYTHONPATH again.
I had a similar exception and could manage to repair it.
In my case I upgraded Ubuntu 16.04 to Ubuntu 18.04.
I had to re-create the virtualenv. Depending on your choice:
virtualenv .
Or
virtualenv --system-site-packages .
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).
creating my first module in django,
I am using mac Tried steps:
1.installed python 3.6.+ version,
2.cloned git project
3.setup local env,
to create a module,
trying with command
env=dev python3 manage.py startapp supriya_module_inflow;
getting error in console :
Environment Selected :dev
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 24, in <module>
import MySQLdb as Database
ModuleNotFoundError: No module named 'MySQLdb'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 35, in <module>
execute_from_command_line(sys.argv)......
...
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'
MySQLdb does not support Python 3. You'll want to pick one of the other MySQL drivers.
At the time of writing, the latest release of MySQLdb (1.2.5) doesn’t support Python 3. In order to use MySQLdb under Python 3, you’ll have to install mysqlclient instead.
Here is How to install mysqlclient in Python using pip so as to be able to import MySQLdb in Django 3.1 when running Python 3.8.5..
The error message indicates that there is no module named MySQLdb. It means, Python needs a module to interface with MySQL database and that modules does not seems to be present in the system. All you need to do is, just install MySQL-Python module and the script should work without any problem.
Using Python Pip
pip install MySQL-python
Collecting MySQL-python
Installing collected packages: MySQL-python
Running setup.py install for MySQL-python
Successfully installed MySQL-python-1.2.5
On Ubuntu based systems
# apt-get install python-mysqldb
On RHEL/CentOS based systems:
# yum install MySQL-python
Using easy_install
# easy_install mysql-python
If you are on a virtual environment then
pip install MySQL-python
You can also check this related issue.
** Building wheel for MySQL-python (setup.py) ... error
ERROR: Command errored out with exit status 1:**
can't able to install MySQL-python and getting the above error .
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!