简体   繁体   中英

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.

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM