Himanshu Poddar
Himanshu Poddar

Reputation: 7799

Django unable to create project using command line

I went through all the solutions but none of that resolves my issue. So while trying to create project using the startproject command on command line. I am getting an error.

Here is the series of steps that I have tried

1. Installed Python
2. Installed Django
3. django-admin startproject mysite

which gives me an error

CommandError: [WinError 2] The system cannot find the file specified: 'C:\\Users\\Himanshu Poddar\\Desktop\\mysite'

However django-admin is working fine though, which gives me a list of Django commands.

My Django version is 2.1.2 and I am using Win10.

Edit

The command is working when I changed my directory to C:\Users\Himanshu Poddar and the file is successfully created but when I am trying same in any other directory I am getting an error.

Upvotes: 0

Views: 1648

Answers (3)

Adnan Mohib
Adnan Mohib

Reputation: 369

I experienced same issue. And it turned out to be issue regarding the python.exe file name. I created virtual environment for python 3.6 and in the envs/env_name folder the name of the file was python.exe instead of python3.exe So I copied the python.exe file in same folder and renamed it to python3.exe. Now I can access the python using both python3 and python commands in command prompt.

Upvotes: 1

Nick D
Nick D

Reputation: 1

I experienced this same issue and found the culprit (at least in my case): Windows 10 ransomware protection, specifically the controlled folder access setting. Turning that setting off and running "django-admin startproject mysite" allows the folder to be created. I turned controlled folder access back on after running the command.

Upvotes: 0

shafikshaon
shafikshaon

Reputation: 6404

For Windows: To run django-admin command you need to activate python virtual enviroment. To create virtual enviroment

python3 -m venv venv

Then activate by

venv\Scripts\activate

Then run

django-admin startproject mysite

ALternative way: Installing virtualenv through pip

pip install virtualenv

Then create venv by

virtualenv venv

and activate by

. .\venv\Scripts\activate

Upvotes: 0

Related Questions