Django install and enviroment are no longer recognized - python

I just went to run my Django development server in the Django project that I'm working on and I got this...
(baseballwebenv) C:\DjangoProjects\BaseballWebsite\baseballweb>python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
File "C:\Users\Nick\Anaconda3\envs\baseballwebenv\lib\site-packages\django\__init__.py", line 1, in <module>
from django.utils.version import get_version
File "C:\Users\Nick\Anaconda3\envs\baseballwebenv\lib\site-packages\django\utils\version.py", line 4, in <module>
import subprocess
File "c:\users\nick\anaconda3\Lib\subprocess.py", line 178, in <module>
from _winapi import (CREATE_NEW_CONSOLE, CREATE_NEW_PROCESS_GROUP,
ImportError: cannot import name 'ABOVE_NORMAL_PRIORITY_CLASS'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 14, in <module>
) 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?
As you can see I am by my runserver command, I am in my virtual environment. I recently upgraded all of my Anaconda packages, thinking everything was protected in the virtual environment. I would suspect this problem is related to that, but I'm not sure. How do I get my project up and running again? If someone wants to see certain files, I can add those as well.

Related

How should I do when conf folder doesn't have global_setteings.py with an error [ cannot import name 'global_settings' from 'django.conf' ]?

When I launch a Django project in a local server, It doesn't work with the errors below,
and then, I checked the directory of conf(/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/conf) and found that global_settings.py doesn't exist in that directory.
in that case, how should I do?
do I have to make the global_settings.py my self in there with this code? or will I be able to solve another way?
Would you mind telling me how should I solve this problem?
Thank you in advance.
__init__.py(global_settings has red lile)
The structure of conf directory
error code after I add global_settings.py in the conf folder my self
Traceback (most recent call last):
File "/Users/apple/GoogleDrive/project_django/harvest_timer/manage.py", line 10, in main
from django.core.management import execute_from_command_line
File "/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 13, in <module>
from django.core.management.base import (
File "/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/core/management/base.py", line 11, in <module>
from django.core import checks
File "/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/core/checks/__init__.py", line 8, in <module>
import django.core.checks.caches # NOQA isort:skip
File "/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/core/checks/caches.py", line 2, in <module>
from django.core.cache import DEFAULT_CACHE_ALIAS
File "/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/core/cache/__init__.py", line 18, in <module>
from django.core import signals
File "/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/core/signals.py", line 1, in <module>
from django.dispatch import Signal
File "/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/dispatch/__init__.py", line 9, in <module>
from django.dispatch.dispatcher import Signal, receiver # NOQA
File "/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/dispatch/dispatcher.py", line 4, in <module>
from django.utils.inspect import func_accepts_kwargs
ModuleNotFoundError: No module named 'django.utils.inspect'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/apple/GoogleDrive/project_django/project/manage.py", line 21, in <module>
main()
File "/Users/apple/GoogleDrive/project_django/project/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?
error code when I run the project using Pycharm
Traceback (most recent call last):
File "/Users/apple/GoogleDrive/project_django/project/manage.py", line 10, in main
from django.core.management import execute_from_command_line
File "/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 11, in <module>
from django.conf import settings
File "/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/conf/__init__.py", line 17, in <module>
from django.conf import global_settings
ImportError: cannot import name 'global_settings' from 'django.conf' (/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/conf/__init__.py)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/apple/GoogleDrive/project_django/project/manage.py", line 21, in <module>
main()
File "/Users/apple/GoogleDrive/project_django/project/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?
error code when I run the project using the terminal
Traceback (most recent call last):
File "manage.py", line 10, in main
from django.core.management import execute_from_command_line
File "/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 11, in <module>
from django.conf import settings
File "/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/conf/__init__.py", line 17, in <module>
from django.conf import global_settings
ImportError: cannot import name 'global_settings' from 'django.conf' (/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/conf/__init__.py)
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?
manage.py
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise 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?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
Python Console
import sys;
...
...print(sys.path)
['/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev', '/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/third_party/thriftpy', '/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload', '/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages', '/Users/apple/GoogleDrive/project_django']
Run/Debug Configurations in Pycharm
[ Script path ]: /Users/apple/GoogleDrive/project_django/project/manage.py
[ Parameters ]:runserver
[ Environment ] variables:PYTHONUNBUFFERED=1;DJANGO_SETTINGS_MODULE=project.settings_dev
[ Python interpreter ]:Python 3.7(project_django) ~/GoogleDrive/project_django/venv/bin/python
[ Working directory ]:/Users/apple/GoogleDrive/project_django/project
Development environment
Mac: mojave 10.14.6
Python: 3.7.5
Django: 2.2.2
Pycharm: 2019.3.1 (community edition)
No you shouldn't create global_settings yourself.
I see you are using Pycharm, try your Python virtualenv interpreter to Pycharm with these instructions: https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html
Then try to start the django project from Pycharm
Assuming you have Django configured in your system.
I think what you are missing is activating your virtual environment.
cd to Django path. /Users/apple/GoogleDrive/project_django/venv/
Run source bin/activate to activate your virtual environment
then cd to your project. All should be working fine then.
I am doing a lot of assumptions though. I am not sure of how exactly you have your development environment setup for django.

Python Manage.py and Pycharm

python manage.py runserver not working in pycharm and giving this error even I have put manage.py in settings of Django in Language & Framework Django Tab.. what it could be?
(venv) C:\Users\ionezation\PycharmProjects\ecomesite\ecs>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?
seems you need to specify python interpreter
File -> Settings -> Project -> Project Interpreter -> icon gear wheel -> Add ->
Existing environment

(windows server 2016) (python/Django) Couldn't import Django

The full error message:
Traceback (most recent call last):
File "manage.py", line 9, in <module>
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django.core'; 'django' is not a package
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 15, in <module>
) 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?
I have tried adding django directly to the PYTHONPATH, no dice
I have created a virtual environment and installed django in it, still nothing
According to pip freeze I got Django 2.1.2 installed
I'm pretty sure I'm using python 3.7.0
Apparently I can import django just fine (by just typing "import django" in an empty test.py file), but when I try to import django.core it gives me the following error:
Traceback (most recent call last):
File "test.py", line 7, in
import django.core
ModuleNotFoundError: No module named 'django.core'; 'django' is not a package
(stackoverflow won't let me format it as code for some reason)

ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable?

i added the python path in environment variable then also it is giving me same error so please anyone can help me
(py1) C:\Users\NIKITA GULHANE\projects\raksh>python manage.py
runserver Traceback (most recent call last): File "manage.py", line
8, in
from django.core.management import execute_from_command_line File
"C:\Users\NIKITA~1\Envs\py1\lib\site-packages\django__init__.py",
line 1, in
from django.utils.version import get_version File "C:\Users\NIKITA~1\Envs\py1\lib\site-packages\django\utils\version.py",
line 1, in
import datetime ModuleNotFoundError: No module named 'datetime'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 14, in
) 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?
I found you have to ensure Django is imported in the file wsgi.py.
Hope this answer is useful

Cant find django module . import error

I have installed Django and it is already in the package. But when i run python manage.py runserver.I am getting 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'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 14, in <module>
) 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?

Categories

Resources