tutorial --- venv --- lib
--- include
--- bin
--- first
--- manage.py
my problem is , trying to open in pychrem and when i try to run the manage.py i have this error.
in terminal evreything work , but in pychrem not .
/usr/local/bin/python3.8 /Users/alekseyzgeria/Desktop/tutorial/manage.py
Traceback (most recent call last):
File "/Users/alekseyzgeria/Desktop/tutorial/manage.py", line 11, 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:**
File "/Users/alekseyzgeria/Desktop/tutorial/manage.py", line 22, in <module>
main()
File "/Users/alekseyzgeria/Desktop/tutorial/manage.py", line 13, 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?
Just go to your command line and type the following:
pip install django
You may have been running your Django project through a virtual environment, you could either download the framework to your main Python environment by running "pip install Django" in your terminal and continue your work however you could also locate your previous virtual environment and activate it by navigating to the venv directory (On Windows it should be your user folder) and running the activate script and then work from there. (If Django wasn't installed on that environment either run the same pip command from earlier)
Related
I'm at my first experience with django and I'm having already a little obstacle: I've menaged to create and use a virtual enviroment successufully yesterday, but today I can't seem to be able to reload it. This is how I'm doing it:
cd /c/website
python -m venv virt
spurce virt/scripts/activate
cd /c/website/project
python manage.py runserver
And this is the error I'm getting
Traceback (most recent call last):
File "manage.py", line 11, 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 "manage.py", line 22, in <module>
main()
File "manage.py", line 13, 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?
(virt)
before doing some mistakes, do I need to reinstall django everytime or I'm just messing up the procedure to reload the ve I created?
Thanks for your help!
When I got the same issue in my windows machine..(probably occurred because I did some C drive repair)
I also can't able to run python manage.py runserver , I got the same error
ModuleNotFoundError: No module named 'Django'
I did the following steps.. to overcome my error:
On my main folder Check If you have already a "requiremnts.txt" file skip this step else run this command: pip freeze > requirements.txt ,if it saves all your packages then only do other steps
Delete Venv folder from the main directory.
Again install virtual environments and activate Venv.
then run this command pip install -r requirements.txt this will install all your packages back.
Run again python manage.py runserver , It will work fine
I have created a package named as patterns along with test.py,
test.py has the following code lines:
from patterns.shapes import *
square()
[Module Error]
I have copied the test.py file to the same location F:, where I trying to run via command prompt.
To gain access to this package from any location I have installed it using pip install . in the windows command prompt, which was successful, but when I try to access the file test.py I am getting the error as below :
F:\>py test.py
Traceback (most recent call last):
File "test.py", line 1, in <module>
from patterns.shapes import *
ModuleNotFoundError: No module named 'patterns'
My package folder is stored in a different drive.
While working on a python project, one must always work in a virtual environment. Please check if you have your virtual environment activated. If not, then follow the steps:
cd your_working_directory
virtualenv environment_name where environment_name can be any name you want.
environment_name/Scripts/activate if on Windows
Or environment_name/bin/activate if on MacOS
Then after activating the environment you can install all the dependencies using pip. i.e pip install patterns
Can anyone help me with following problem? I encountered that during one of the courses I am taking.
I use ios Catalina 10.15 therefor I use zhs as bash is no longer supported by mac
I am trying to run virtual server so I can see my webpage
I managed to run the virtual server once only (python manage.py runserver) and after the restart I have problem with it eversince.
> first_proj python manage.py runserver
Traceback (most recent call last):
File "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 "manage.py", line 21, in <module>
main()
File "manage.py", line 16, in main
) from exc
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?
when I check for django (django-admin --version), turns out it is installed, I am getting this ouput:
2.2.5 (version of Django installed).
my django directory is: /Users/myname/opt/anaconda3/envs/projectname/lib/python3.8/site-packages/django
maybe it is something about the directory django is installed (?)
thanks for any help.
First of all I recommend you to install Anaconda in /opt/anaconda3, not in /somepath/opt/anaconda3. And when you install it, accept the auto-init.
Second, Zsh and Anaconda must be configured separately so they can work together. Add Anaconda to your paths (/etc/paths). You can check to see if everything is going well by applying any conda command:
$ conda info -e
Third, remember to activate your environment before applying runserver.
$ source activate <conda-env-name>
Using this command, you can see all the libraries installed in your environment: (and check if django is there)
(<conda-env-name>) username#mac: ~ $ conda list -e
And then make runserver:
(<conda-env-name>) username#mac: ~ $ python3 manage.py runserver
I am attempting to configure a virtual environment on a Windows machine with virtualenv and I have been unable to to run manage.py
I reviewed a few other stackoverflow answers (Running django in virtualenv - ImportError: No module named django.core.management?) and was unable to resolve the issue that I am having.
Here is where I am at...
C:\Users\tyarboro\Documents\Project (master)
(venv) λ pip freeze
Django==1.7
django-admin-sso==2.1.0
django-social-auth==0.7.28
httplib2==0.9.2
json2html==1.0.1
oauth2==1.9.0.post1
oauth2client==2.2.0
pyasn1==0.1.9
pyasn1-modules==0.0.8
python-openid==2.2.5
rsa==3.4.2
six==1.10.0
C:\Users\tyarboro\Documents\Project (master)
(venv) λ manage.py
Traceback (most recent call last):
File "C:\Users\tyarboro\Documents\Project\manage.py", line 9, in <module>
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
I have attempted the following modifications to the manage.py
Removed the first line of the file #!/usr/bin/env python
Set the sys.path.append to the directory that contains the site-packages in my virtual environment.
sys.path.append('C:\Users\tyarboro\Documents\Project\venv\bin\activate\Lib\site-packages')
I think the issue is that the virtual environment is running Python outside of the virtual environment instead of within the virtual environment. Any suggestions on how to fix this?
Thanks!
Try to install Django using built-in pip module:
pip install django
This command should install packages into site-packages directory.
refer this doc : install-python-django-on-windows
I am trying to use virtualenv.
I installed it on my ubuntu system followed simple steps given here
but when I activate my virtual environment and try to do
$ python manage.py runserver
it throws 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.core.management
I tried to see if django is accessible from my virtual env so it tried to
$ python
>>> import django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named django
and the same import django works fine out of the virtualenv.
I also tried to delete the django folder from root python setup and reinstalling it. but all in vain, the problem is still the same. What should I do now ?
PS: I tried to run easy_install Django & easy_install django gazillion times from the virtual env everytime it says django is already their.
PPS: I dont know if it is of importance but their was a django installation present prior doing all this in the system.
Check your manage.py, the first line needs to define the python executable, usually #!/usr/bin/env python. This should be the path to the python executable in your virtualenv and not to the global executable. If you had installed Django system wide this wouldn't be a problem.
Just in case
virtualenv venv
source venv/bin/activate
python manage.py runserver
[Adding this info for Windows users who hit the same problem]
If you're running into this problem on Windows then make sure that your virtual env is active (your prompt will be something like (venv) d:\myproject) and that you're running python.exe explicitly.
On the latter point, do not run py.exe (the Python Launcher introduced in 3.3) or rely on a .py file association to run Python. Both of those will run a version of Python outside of your virtual env and therefore will have the wrong site-packages.
If your virtual env has django 1.8.6 but your core Python installation does not have django, then:
python -c "import django;print(django.get_version())" will work and print 1.8.6
py -c "import django;print(django.get_version())" will fail with "ImportError: No module named django"