I'm new to django and I would like to follow this tutorial: https://docs.djangoproject.com/en/2.1/intro/tutorial01/
Unfortunately, django-admin is not in my path.
When I try to run the django-admin.py script directly, I have the following error:
$ /usr/local/lib/python3.7/site-packages/django/bin/django-admin.py
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/django/bin/django-admin.py", line 2, in <module>
from django.core import management
ImportError: No module named django.core
Here is my configuration:
- System: macOS 10.13
- Python: 3.7.0 (installed via Homebrew
- Django: 2.1.4
What am I doing wrong?
-
stackoverflow.com/questions/312549/no-module-named-django-corePranay reddy– Pranay reddy2018年12月10日 12:11:10 +00:00Commented Dec 10, 2018 at 12:11
2 Answers 2
I think You don’t install django correctly. If you are highly new in django then follow these steps to setup your clean and new project environment
Create your project folder
mkdir myProject
Open this Project Folder
cd myProject
Create virtual environment
python3 -m venv env
Now, active this virtual environment
source env/bin/activate
It’s time to install the Django
pip install django
Create your first project
django-admin startproject myProject
Open this Project
cd myProject
Open your server to check it either it’s work successfully or not
python manage.py runserver
1 Comment
First check if django is installed by running python -c "import django". If that is successful check if django-admin command is in your python path. If you are using a virtual environment check under virtual environment/bin/. If there is no file such as django-admin then the first solution would be to try reinstalling django. Same case if you are working outside a virtual environment.
If none of the above solves it then check if you have both python 2 and 3. If you do check whether .py files are being associated to python 2 instead of python3.
1 Comment
/usr/local/lib/python3.7/site-packages/django/bin would help in anyway.