So I am trying to follow along some instructions from a course, anyhow I encounter the following error:
File “C:\Users\hermi\Envs\cf-python-base\base-new\Lib\site-packages\django\conf_init_.py”, line 82, in _setup
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Requested setting USE_I18N, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
my Repository path looks like this:
C:\Users\hermi\Documents\GitHub\Python-Fullstack-Project\achievement 2\ex 2_2> within achievement 2 I have there my venv.
I have started with the following commands:
activate my venv
django-admin.exe startproject bookstore
I somehow can not use py or python manage.py
Is there anything else I might need to provide?
manage.py file-
#!/usr/bin/env python
“”“Django’s command-line utility for administrative tasks.”“”
import os
import sys
def main():
“”“Run administrative tasks.”“”
os.environ.setdefault(‘DJANGO_SETTINGS_MODULE’, ‘bookstore.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()
Your current directory should be the directory in which the manage.py
command resides, and within the context of a project, you should run python manage.py migrate
and not django-admin migrate
. (You can use django-admin
if you really wanted to, but you’d need to set the right environment before running it. That’s primarily what the manage.py
command does for you.)
Good to know, my issue is though that after trying python manage.py migrate I get: [Errno 2] No such file or directory.
I seems straight forward but I do not understand why can that be.
Side note: Please try to avoid posting images of code or other text here. Copy/paste the text into the body of your post, surrounded between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```. This forces the forum software to keep your text properly formatted. (You could have done the same with the text that you did post underneath the image.)
I see you’re trying to use Powershell here.
What happens if you just enter python
from the Powershell prompt? If you don’t get the Python interpreter, then you may need to configure VS Code for Python (see Python on Windows for beginners | Microsoft Learn)
Personally, I avoid Powershell, so I don’t have any real personal knowledge to draw on here. I have my VS Code configured to run the standard Command Prompt shell in VS Code for those few cases where I’m actually developing in Windows. You might want to search the forum here for Powershell
to see where this has been discussed in other threads.