I\'ve already configured virtualenv in pycharm, when using the python manage.py command, this is error shown:
E:\\video course\\Python\\code\\web_worker\\MxO
If you are working on a machine where it doesn't have permissions to all the files and moreover you have two versions such as default 2.7 & latest 3.6 then while running the command use the python version with the command. If the latest python is installed with sudo then run the command with sudo.
exp:
sudo python3.6 manage.py runserver
I had same problem, I installed all dependencies with root access :
In your case:
sudo pip install django
In my case, I had all dependencies in requirements.txt
, So:
sudo pip3 install -r requirements.txt
If you are using python 3 use py
in front of cmd code, like this
py manage.py runserver
Check that you have installed Django; by executing import django
in python.
you mustn't see ModuleNotFoundError
if everything's ok.
Check that you have installed virtualenv; by executing virtualenv --version
.
you must see the version number if everything's ok.
Check that you have enabled virtualenv; there's got to be the name of your virtualenv in your command prompt starting line. enable it by
source bin/activate
. also, remember to deactivate
it every time your job is
finished with the virtualenv.
Check that your virtualenv includes django. a virtualenv by default
has no modules installed. you either have to install django in your
virtualenv (even if you have it in your machine already) or use
virtualenv --system-site-packages
when creating a virtualenv to
include system site packages in the virtualenv.
Add django to your path. open python, import django
, then run
django
to see django's path. then add it to your ~/.bashrc
(or
~/.zshrc
if you're using zsh
). more info in here
Install django-admin
by running pip install django-admin
I was having great difficulties with this but I have solved my issue. I am on Windows 10 using Vagrant ssh in my virtualenv environment, the box I have installed is ubuntu/xenial64, Django version 2.1, python==3.6.
When I was installing packages I was using pip3 but most importantly I was using sudo and the -H
flag to install these packages. When I ran sudo pip3 freeze
my packages would come up, but when I ran a plain pip3 freeze
there would be no packages.
Then I tried the python3 manage.py startapp <YOUR APP NAME>
and it did not work same error as you.
I finally thought to try sudo python3 manage.py startapp <YOUR APP NAME>
it finally worked!
Hope this was help :)
find your django parent dir path and add it to PYTHONPATH
In my case, my django parent dir path is /Library/Python/3.7/site-packages
,add this line into ~/.bash_profile
export PYTHONPATH=/Library/Python/3.7/site-packages
else if you have PYTHONPATH already, just append it like this
export PYTHONPATH=${PYTHONPATH}:/Library/Python/3.7/site-packages
then
source ~/.bash_profile