command "django-admin.py startproject mysite" not recognized - django

EDIT: I added the path to django-admin.py to my system path (C:\Users\me\Downloads\Django-1.5.1\django\bin) but even after this when I try to run django-admin.py startproject mysite, it asks me to pick a file to open with and even when I pick python.py, it opens in chrome for some reason. I also tried python django-admin.py startproject mysite but it says
python: can't open file django-admin.py: [Errno 2] No such file or directory
Any idea what is wrong?
I added python27 to the system path and when I open up cmd and switch to a directory (C:\Users\me\djcode) and then type in django-admin.py startproject mysite it says
django-admin.py is not recognized as an internal or external command, operable program or batch file
When I try typing the command python django-admin.py startproject mysite, it says
python: can't open file django-admin.py: [Errno 2] No such file or directory
Any idea why?
In the djangobook (http://www.djangobook.com/en/2.0/chapter02.html) it says
django-admin.py should be on your system path if you installed Django via its setup.py utility
what does this mean? how do I add django-admin.py to my system path? I am not sure where django-admin.py even is.

Working !!
If you are using window then first of all
create virtual environment
python -m venv venv
Then activate that environment
venv\Scripts\activate
Then install Django in that environment
pip install django
Then create django project named mysite
django-admin startproject mysite

I have the same problem because i have installed Django Manually. The solution for resolve :
Install Python https://www.python.org/downloads/ (if not installed)
Verify your Path : https://stackoverflow.com/a/17836439 It's very important or the next no work.
Install setuptool : Download the .py file here : https://bootstrap.pypa.io/ez_setup.py and execute this with python.
Install PIP with this command : easy_install pip
Clean Django : pip uninstall django
install Django : pip install django
Execut django-admin.py startproject mysite and enjoy.
If not OK, test django-admin-script.py startproject mysite. If is ok, your django installation is wrong.
Sorry for my bad english, i'm french :)

Find the folder where django-admin.py is located. Then go to Control Panel > System > Advanced System Settings > Environment Variables . In the User Variables and/or System Variables, search for an entry called PATH. Modify it by adding the folder you found earlier, use the other entries as guidance, basically just make sure they're separated by ;. If you have done all these steps, but are still in the same cmd prompt that you were using before doing them, close it and open a new one so it picks up on your changes.

For windows, the "django-admin" you need to create a project is an .exe file not a .py file and it is present at the following location:
C:\Python27\Scripts
so you have to add this location to your path.

After running pip install django wait for the setup to finish and
present you with a warning.
From the warning copy the path of where django is installed. In my
case it is
C:\Users\USERNAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8\LocalCache\local-packages\Python38\Scripts
Add that to PATH in environment variables and restart cmd or shell.

Try this: django-admin startproject mysite

I have tried all of the mentioned things however I was still unable to create a project using django-admin startapp appname. So I used python -m django startproject appname instead and was able to create the proejct

If it did not work for you even if you tried the command :
django-admin startproject mysite
Here's what worked for me:
Uninstall django
pip uninstall django
Add the below path to the PATH variables-
C:\Users\System_Name\AppData\Roaming\Python\Python39\Scripts
Note: In the above path, System_Name refers to the name of your laptop/pc.
Install django again
pip install django
You can check the version of django using django-admin --version

I've just created project using :
py -m django startproject Yourprojectname

You need to install django. It seems you have just downloaded it and expanded the archive.
Install setuptools
Install pip
Open a command prompt and then type pip install -U django (or, you can download the windows installer).
Once you have done the above steps, you need to make sure C:\Python27\Scripts is in your PATH; otherwise the commands will not work.
To set PATH, go to Environment Variables from My Computer (right click and then go to Manage, then on the left, Advanced Settings).
Finally, you'll need to run python django-admin.py and not django-admin.py

this one workked for me
python 2.6.6
django 1.6.11
python C:\Python26\Scripts\django-admin.py startproject myapplication

Try using. exe instead of .py.
It worked for me

Add the following address in the system path
C:\Users\{username}\AppData\Roaming\Python\Python39\Scripts
{username} : enter your username

Try this command: python -m django startproject myapp

I faced the same problem and tried many ways. Solved my problem by following these steps
Python installation manually
in my cmd
pip install Django
pip install djangorestframework
pip install django-cors-headers
pip install virtualenvwrapper-win
Windows+r
sysdm.cpl
In Advanced Option, Environment Variables> In user variable edit
path
C:\Users\mushf\AppData\Roaming\Python\Python310
C:\Users\mushf\AppData\Roaming\Python\Python310\Scripts
In System Variable> Edit
path
C:\Program Files\Python310\Scripts\
C:\Program Files\Python310\
After that create my project folder in the desired location:
django-admin start project ProjectName
My preferable IDE is pycharm

Instructions for Windows
You must have pip on your machine.
Open Visual Studio and open the project folder.
Open terminal from VS, Terminal tab. Go to the project directory.
pip3 install virtualenvwrapper
This must be done only the very first time you are setting up your environment.
Then run:
python -m venv env
Installs the needed files for running a virtual environment. You should see a folder added now. Create a virtual environment. Now activate it (i.e. start working in the virtual environment):
activate environment env\Scripts\activate
if activate doesn't work use this
env\Scripts\activate
Install Django in a virtual environment. If you want a specific version run:
pip install django==3.0.3
For the latest version just run:
pip install Django
To check the existing version:
pip freeze
To create a new project:
django-admin startproject simplesite
cd simplesite
python manage.py startapp helloworld
will create a new application in the project with a folder "helloworld"
python manage.py runserver 127.0.0.1:8080
Open in your browser http://localhost:8080 to test the running server.
Ctrl+C to stop the server.

copy the Django-admin.exe file into the folder you are using. the file can be found at python/python(version)/scripts. when you finish a folder should pop up in the name of your file

Just copy the Django admin.py file which is present actually where you have installed python in C:\program files\Python or in my case it was located at administrator\appdata\local\programs\python you can check yours and just copy the file that is Django admin from script folder to your newly created folder

I needed to update my System Environment Variable path so this answer helped me:
Add “django-admin.py” path to command line on Windows

You will have to activate the environment (env) before you run the command:
django-admin startproject myapp
I had the same problem.

For Windows user:
Step 1: Open cmd in the project directory
Step 2: Run this in cmd : python -c "import django; print(django.__path__)"
Step 3: Go to the path and copy django-admin.exe to the current project directory
Step 4: Run this in cmd : django-admin startproject DEMO
Happy Learning,
Thank you

Before you run django-admin.py startproject mysite
1) You need to create a virtual enviroment on the folder that you want to store your project
so run pipenv install django==2.1 (if you dont have pipenv installed run
pip install --user pipenv)
2) To run this virtual enviroment run pipenv shell
3)And finaly django-admin.py startproject mysite
Hope this works

In my case I made a mistake installing django in a wide system manner and then it created /usr/local/bin/django-admin I uninstalled django through pip but it doesn't remove those files then when you type the command it tries to invoke that file but as it says the module django is not present.
Just remove those orphans files (use sudo if needed)
sudo rm /usr/local/bin/django-admin
sudo rm /usr/local/bin/django-admin.py
and try again (with your virtualenv activated) and it should takes the right module and works as usual!

This is my solution:
step-1 --add environmental path
C:\Users\DELL\AppData\Local\Programs\Python\Python38
C:\Users\DELL\AppData\Local\Programs\Python\Python38\Scripts
step-2 pip install django
step-3 --run command in specific folder
django-admin.py startproject mysite

For me, a simple fix was reinstalling python. It turns out I didn't select add to path, when installing python the first time, and that is crucial.

if you are using windows then goto (search)"advanced system settings/Environment veriables/New path" and add path of your python packeges folder, in my case its "C:\python38\Lib\site-packages".
may be you have other path of site-packages folder.

If you are using Pycharm then after creating New project just go to the file-->setting-->project-->serch Django-->install Django then go to the terminal type django-admin startproject name(whichever you want) press enter

Run CMD as Administrator
pip3 install django

If you had this error occur on windows after installing django using pip that has the message along the following lines:
could not install packages due to an OSError: [WinError 2] The system
cannot find the file specified: 'c:\python39\Scripts\sqlformat.exe'
-> 'c:\python39\Scripts\sqlformat.exe.deleteme'
Which in turn causes the same problem as the question stated. A working solution is to clean installing django which you can do by using pip uninstall django, and then reinstalling it by running the install command like this: pip install --user django.
If no other warnings or errors occur, then it should be fixed. In case a warning sating that the django-admin.exe file is located at some location that needs to be added to the path variable, you can copy that path and add it to the path variable under your environment variable settings.
Quick fix guide:
Uninstall django: pip uninstall django.
Reinstall django: pip install --user django.
If a warning occurs containing a path continue to step 4 otherwise it should be fixed, and you may skip to the bottom.
Copy the path that should be added to the PATH environment variable.(the one specified in the warning)
Click on the start menu button.
Search for Control Panel and click on it.
Change the View by: option to Large icons.
Click on the System item.
Click on the Advance system settings button.
The System Properties window will open, proceed to click on the Environment Variables... button at the bottom right.
A new window will open displaying your Environment Variables, on the first gird select the row with the name of PATH or Path or path under the Variable column.
Then click the Edit button just below the grid.
A new window will open, proceed to click on the New button and paste the path you copied earlier.
After pasting press the Enter key and proceed to click on the OK button.
Once the window closes and you're back in the Environment Variables window proceed to do steps 11 to 14 again only with the grid at the bottom(inside the System Variables group).
Once all these steps were followed you may click on the OK button in the Environment Variables window and close out of all the other windows that are still open after you followed these steps.
Close your CMD window and open a new one (this allows it to recognize the changes you made to your environment variables).
After following these steps, you should be able to continue with what you were doing without having any other difficulties further regarding Django

I wasn't getting the django-admin to run even after an hour of configuring PATH etc. That was all completely useless.
What actually WORKED was running the windows terminal (cmd) as admin and then doing "pip install django". Be sure to first uninstall it though using "pip uninstall django", so that you get a clean installation.
Now django-admin runs perfect on cmd with or without admin rights.

Related

Django Start project not working after install

The django project will not create. I keep getting this same error, please help. I am not sure what else can be done.
As suggested by #Flux in your comment, use django-admin to start your project.
django-admin startproject winsdompets
You can refer to this question to ensure your django-admin path is one of your environment variables.
By the way, to avoid those environmental issues in Mac or other platform, you can try to use pipenv to manage your Django environment.
The following are instructions for Mac users.
# path/to/your/project/directory
brew install pipenv
# It will create a new env and open a terminal shell, or open an existing env if there are pip settings files
pipenv shell
pip install Django
django-admin startproject winsdompets
You should activate the python environment before you create a project.
1. check the path of "django-admin"
sudo find / -name "django-admin"
2.check the path of "python"
which python
If the paths are different, activate python in the directory of "django-admin".
eg. the path of "django-admin" is /var/www/env/bin/djang-admin
source /var/www/env/bin/activate

Python venv not creating virtual environment

I'm trying to create a virtual environment for my current Django project using
python3 -m venv env
however the command doesn't create any directory with bin/include/lib folders.
What exactly am I missing here?
I have a Windows 10 machine and had a same problem. It was because I had multiple versions of python. Unknowingly windows had created a python.exe in the WindowsApps folder -
Then the solution is sometimes:(there is a huge chance that, the old %PATH% got renamed)
py -m venv venv
This python.exe had a size of 0 kb, so I deleted the python.exe in the WindowsApps folder, opened a new Command prompt and it started working.
Sometime system's path environment is not aware of virtualenv.exe
solution:
install virtualenv
pip install virtualenv
run command in the directory where you want virtual environment :
python3 -m virtualenv venv
For anyone facing this issue now, simply changing the command to start python instead of python3 fixes this
why do you have to write python3 -m venv env when you base is installed as python3.6 itself?
Just do pip install virtualenv this should install virtualenv package if not already installed, then
virtualenv envname this will run and should give you a message like this, I have created a env called testenv:
C:\Users\Admin\python_projects\venvs>virtualenv testenv
Using base prefix 'c:\\python37'
New python executable in C:\Users\Admin\python_projects\venvs\testenv\Scripts\python.exe
Installing setuptools, pip, wheel...
done.
If you get this, it is a success, else do let us know what you get, after this you must cd into the Scripts folder and then run activate
I was having this same problem. I was able to get venv working by uninstalling Python and reinstalling it (I'm using the Anaconda distribution). The py -m venv test command still doesn't have any output after running it, but now it creates a folder for me and I can activate the test environment.
Try this (works for me)
python -m venv C:\<optional-EXISTING-directory-path>\<VENV-name-u-want-2-use>
For more info: https://docs.python.org/3/library/venv.html
Install and create through:
pip install virtualenv
virtualenv <your_virtualenv_name>
Then activate the environment, by going to ./your_virtualenv_name/Scripts folder and then run:
activate
I guess I am a bit late to answer the question, but before creating a virtual environment always check if we already have a .venv hidden folder
Navigate to the directory where we want to create a virtual environment
Check if we already have one by ls -la this command will show us the hidden folders, as .venv will be hidden by default
If we do not have the .venv folder (name is up to us), then create one by mkdir .venv to follow the best convention, in this folder we can create multiple virtual environments
Now we can create a virtual environment by python3 -m venv ./venv/drf
In above folder we have created, inside that we are creating one more folder drf (Django Rest Rramework)
At last to run our virtual environment use source .venv/drf/bin/activate by this command we are running the script which is there in bin folder
I hope I was able to explain, as I am also learning
Please feel free to edit or make any changes in the post, If something is wrong
pip install virtualenvwrapper-win
try to install it and do it again
I just had the similar problem, and I realized changing the path directories names by removing the spaces in the name of the directories helps.

ImportError: Couldn't import Django

I've already configured virtualenv in pycharm, when using the python manage.py command, this is error shown:
E:\video course\Python\code\web_worker\MxOnline>python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 17, in <module>
"Couldn't import Django. Are you sure it's installed and "
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?
How should I fix it, I've installed django.
I think the best way to use django is with virtualenv it's safe and you can install many apps in virtualenv which does not affect any outer space of the system
vitualenv uses the default version of python which is same as in your system
to install virtualenv
sudo pip install virtualenv
or for python3
sudo pip3 install virtualenv
and then in your dir
mkdir ~/newproject
cd ~/newproject
Now, create a virtual environment within the project directory by typing
virtualenv newenv
To install packages into the isolated environment, you must activate it by typing:
source newenv/bin/activate
now install here with
pip install django
You can verify the installation by typing:
django-admin --version
To leave your virtual environment, you need to issue the deactivate command from anywhere on the system:
deactivate
When you install Django on your computer all things go fine but when you install a Virtual environment it gets separated from all things. You will know it's importance when you will make a final project and deploy it to any cloud or hosting.
Just reinstall Django in the virtual environment and baam:
pip install Django
and then just run the command for testing:
python manage.py runsever
and you are all done.
You need to install Django, this error is giving because django is not installed.
pip install django
You need to use both commands:
pip install django and pip3 install django
that worked for me
Check that you have installed Django; by executing import django in python.
you mustn't see ModuleNotFoundError if everything's ok.
Check that you have installed virtualenv; by executing virtualenv --version.
you must see the version number if everything's ok.
Check that you have enabled virtualenv; there's got to be the name of your virtualenv in your command prompt starting line. enable it by
source bin/activate. also, remember to deactivate it every time your job is
finished with the virtualenv.
Check that your virtualenv includes django. a virtualenv by default
has no modules installed. you either have to install django in your
virtualenv (even if you have it in your machine already) or use
virtualenv --system-site-packages when creating a virtualenv to
include system site packages in the virtualenv.
Add django to your path. open python, import django, then run
django to see django's path. then add it to your ~/.bashrc (or
~/.zshrc if you're using zsh). more info in here
Install django-admin by running pip install django-admin
find your django parent dir path and add it to PYTHONPATH
In my case, my django parent dir path is /Library/Python/3.7/site-packages,add this line into ~/.bash_profile
export PYTHONPATH=/Library/Python/3.7/site-packages
else if you have PYTHONPATH already, just append it like this
export PYTHONPATH=${PYTHONPATH}:/Library/Python/3.7/site-packages
then
source ~/.bash_profile
I was having great difficulties with this but I have solved my issue. I am on Windows 10 using Vagrant ssh in my virtualenv environment, the box I have installed is ubuntu/xenial64, Django version 2.1, python==3.6.
When I was installing packages I was using pip3 but most importantly I was using sudo and the -H flag to install these packages. When I ran sudo pip3 freeze my packages would come up, but when I ran a plain pip3 freeze there would be no packages.
Then I tried the python3 manage.py startapp <YOUR APP NAME> and it did not work same error as you.
I finally thought to try sudo python3 manage.py startapp <YOUR APP NAME> it finally worked!
Hope this was help :)
I faced the same issue, and in my case it was because I had multiple python versions on my machine, in addition to the Anaconda ones.
In my case django didn't worked well with my anaconda python.
I knew that when I run import django on each python terminal for all versions I have.
As a summary here are the steps I made to get this solved:
Run the CMD as Admin
Create a project folder.
Create a new ENV for this new project INSIDE THE PROJECT Folder...
pip install virtualenv >> virtualenv new_env`
Activate it:
.\new_env\Scripts\activate`
After the env activation ⇒ Install Django:
python -m pip install Django
The python version you used here in step 5 will determine which python will to work with this installed Django.
If you are working on a machine where it doesn't have permissions to all the files and moreover you have two versions such as default 2.7 & latest 3.6 then while running the command use the python version with the command. If the latest python is installed with sudo then run the command with sudo.
exp:
sudo python3.6 manage.py runserver
after activating virtual env that error raises up on ubuntu.
and I solve this issue just by typing again :
pip3 install Django
inside the directory which is I want to create a new app.
You can use python3 to run file, if you don't want to use virtualenv.python3 manage.py runserver
To install python3 look at this page
Make sure you have Django installed by writing this command :
python -m django --version
if it's not installed you can install it by writing this command :
pip install django
I solved this problem in a completely different way.
Package installer = Conda (Miniconda)
List of available envs = base, djenv(Django environment created for keeping project related modules).
When I was using the command line to activate the djenv using conda activate djenv, the base environment was already activated. I did not notice that and when djenv was activated, (djenv) was being displayed at the beginning of the prompt on the command line. When i tired executing , python manage.py migrate, this happened.
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 deactivated the current environment, i.e conda deactivate. This deactivated djenv. Then, i deactivated the base environment.
After that, I again activated djenv. And the command worked like a charm!!
If someone is facing a similar issue, I hope you should consider trying this as well. Maybe it helps.
Instead of creating a new virtual environment, you just have to access to your initially created virtual environment when you started the project.
You just have to do the following in your command line:
1)pipenv shell to access the backend virtual environment that you have initially created.
2) Then, python manage.py runserver
Let me know if it works for you or not.
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 setup 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.
Install Django
Django can be installed easily using pip within your virtual environment.
In the command prompt, ensure your virtual environment is active, and execute the following command:
py -m pip install Django
In case you have virtual env activated, django installed, django-admin --version prints the valid version - check if there is no circular import in the file you are executing.
I faced the same problem when I was doing it on windows 10. The problem could be that the path is not defined for manage.py in the environment variables. I did the following steps and it worked out for me!
Go to Start menu and search for manage.py.
Right click on it and select "copy full path".
Go to your "My Computer" or "This PC".
Right click and select "Properties".
Select Advanced settings.
Select "Environment Variables."
In the lower window, find "Path", click on it and click edit.
Finally, click on "Add New".
Paste the copied path with CTRL-V.
Click OK and then restart you CMD with Administrator privileges.
I really hope it works!
Looks like you have not activated your virtualenv when using the runserver command.
Windows: <virtualenv dir>\Scripts\activate.bat
Linux: source <virtualenv dir>\bin\activate
You should see (name of virtualenv) as a prefix to your current directory:
(virtualenv) E:\video course\Python\code\web_worker\MxOnline>python manage.py runserver
windows :
(virtualenv dir)\Scripts\activate # this step to activate virtualenv
you should be in the dir of (project name)
python manage.py runserver
you need to go to the root directory
and run the below command
source bin/activate
Once the above command is executed, you will be able to create custom apps
I also face the same problem in windows 10 with anaconda
For me anaconda3\Scripts>activate
it's working good. What you have to do you just need to go to anaconda home
AppData\Local\Continuum\anaconda3\Scripts
and you need to open a cmd prompt and type activate.
It will activate the venv for you.
if you don't want to deactivate or activate the already installed venv just ensure you have set the pythonpath set
set pythonpath=C:\software\venv\include;C:\software\venv\lib;C:\software\venv\scripts;C:\software\venv\tcl;C:\software\venv\Lib\site-packages;
and then execute
"%pythonpath%" %venvpath%Scripts\mytestsite\manage.py runserver "%ipaddress%":8000
The problem is related to this error: Execution Policy Change
Start virtualenv by running the following command:
Command Line
C: \ Users \ Name \ yourdjangofilesname > myvenv \ Scripts \ activate
NOTE: On Windows 10, you may receive an error by Windows PowerShell that the implementation of these scenarios is disabled on this system. In this case, open another Windows PowerShell with the "Run as Administrator" option. After that, try typing the following commands before starting your virtual environment:
C:\WINDOWS\system32> set-executionpolicy remotesigned
Execution Policy Change:
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose you to the security risks described in the about_Execution_Policies help topic at http://go.microsoft.com/fwlink/?LinkID=135170.
Do you want to change the execution policy? [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): A
After selection Y(es), close the Powershell admin window, and then go back to the Powershell Window(where you got the error) and run the command again.
> myenv\Scripts\activate and then python manage.py runserver 8085 ,
(8085 or any number if you want to change its default port to work on otherwise you dont need to point out anything. )
I had same problem, I installed all dependencies with root access :
In your case:
sudo pip install django
In my case, I had all dependencies in requirements.txt, So:
sudo pip3 install -r requirements.txt
Just sync your pipenv environment with:
pipenv sync
I had this problem with Django 3.
On manage.py detail the execute_from_command_line import.
You should have:
from django.core.management import execute_from_command_line
Instead of
from django import execute_from_command_line
I had the same problem and my solution was not posted here:
How I got the error
My error came whenever I was installation the requirements.txt file with pip (let's say from cloning a git repository).
Solution
I manually installed each of the modules in the requirements.txt + any other module needed for the installation of those modules (e.g: I got errors and some modules where missing to install other modules so I had to add them too).
If there is anyone who faced with the same problem when using virtual environment and running on MacOS, just try
sudo python manage.py startapp <project_name>
instead of
python manage.py startapp <project_name>
It will solve the problem suprisingly!
I had to install django using the virtual environment pip3 executable directly:
cd [virtual environment folder]/bin
sudo ./pip3 install django
If you already installed Django / configured virtualenv and you still having the error:
ImportError: Couldn't import Django. Are you sure it's installed and
available on your PYTHONPATH environment variable?
Try to run the command pipenv shell before start the server with py manage.py runserver

how to start a new django project from any directory

I'm running a windows 8 machine. I've installed django using pip and everything looks to be done correctly. running python 2.7 and have django 1.6 installed.
python c:\python27\scripts\django-admin.py startproject mysite
this is the only way I've found to start a new project from any directory; otherwise I would have to make my project and run it from that specific folder. I want to be able to just:
python django-admin.py startproject mysite
from any directory - or more simply:
django-admin.py startproject mysite
from anywhere. I have:
c:\python27\;c:\python\scripts\
in my environment variables.
Not a windows guy, but try running the command from the directory where you want your site to live.
cd C:\Sites
python django-admin.py startproject mysite
If that doesn't work, then is that you don't have Django in your PATH. Add Django to your PATH. Otherwise you'll have to do
python C:\path\to\django-admin.py startproject mysite
Also check out https://docs.djangoproject.com/en/dev/intro/install/ for more documentation on setting up your Django environment.
Hope that helps!
You could create a .cmd file that contains
python c:\python27\scripts\django-admin.py %1 %2 %3 %4 %5
name it django-admin.cmd and put it in c:\windows\system32
Then you should be able to
django-admin startproject mysite anywhere
it seems like the problem is the .py files's default open way.
first, find a .py file.
right click on it,and select "open with" , here u should use python as your default open mode
then restart your cmd, it should be worked.
here is another same problem Can't open file 'django-admin.py': [Errno 2] No such file or directory
You can use virtualenv's. After creating an env, installing django, and activating and env django-admin commands should become available. A recent similar question.

Django local install on ubuntu

I am trying to install django locally on ubuntu but cannot get it to recognize admin-django.py. I performed the subversion checkout, moved the django directory on to the python path and then created a symlink to django-admin.py. I can import django from within the python interpreter but cannot run
django-admin.py startproject mysite
Any ideas what I could be missing?
You probably need to give the full path to django-admin.py. Giving us the error message would help.
If your symlink is in the current directory (you don't say) then:
./django-admin.py
should work. Otherwise its
/usr/wherever/python/site-packages/something/django/huh/django-admin.py
Make sure that the django-admin.py file is executable:
chmod +x django-admin.py