Windows 11 Home - Unable to run django-admin
I have looked through several post regarding either: django-admin : The term 'django-admin' is not recognized or [Errno 2] No such file or directory
I am trying to run django-admin startproject...and again I have tried it several ways and keep getting one of the two above errors.
I've used the full path to python, I have used variations of that command that I have seen in several post but none are working.
I am able to run "python -m django --version" and I get 5.1.
I can run a .py file in the terminal window fine. But can't use "django-admin".
Here is one of the full errors: C:\Users\Famil\AppData\Local\Microsoft\WindowsApps\python.exe: can't open file 'C:\Alejandro\Django\django-admin.py': [Errno 2] No such file or directory
Please advise, this is so crazy.
Cheers
The docs recommend installing Django in a virtual environment. You don't seem to be using one.
To create a virtual environment for your project, open a new command prompt, navigate to the folder where you want to create your project and then enter the following:
py -m venv project-name
This will create a folder called ‘project-name’ if it does not already exist and set up the virtual environment. To activate the environment, run:
project-name\Scripts\activate.bat
The virtual environment will be activated and you’ll see “(project-name)” next to the command prompt to designate that. Each time you start a new command prompt, you’ll need to activate the environment again.
Then go ahead and install Django by running:
py -m pip install Django
This will download and install the latest Django release.
After the installation has completed, you can verify your Django installation by executing django-admin --version in the command prompt. Your django-admin commands would work well.
Well, I found a post:
django-admin: The term 'django-admin' i
I put in the below code and it worked!
Hope this helps someone. Cheers
python -m django startproject myfirstproject