when i type in the command prompt
django-admin.py startproject mysite
the django-admin.py will open automatically with pype,
now if i type cd mysite it says the system cannot find the path specified
I'm using activepython (i don't think that activepython has anything to do with it), django installed using pypm. I can create a project in pydev, not in the command prompt, about a year ago when i first installed activepython, it used to work but as far as i can remember i deleted a django project and it won't work anymore.
how to fix it?
EDIT
#Mikko Ohtamaa
mysite folder does not exist,i see on pype that it has opened the file from C:\Documents and Settings\Administrator\Application Data\Python\Scripts\django-admin.py
but the path is incorrect i don't have an application data folder in C:\Documents and Settings\Administrator\
I have searched the entire pc and haven't find a folder, furthermore in you run this 100 times
django-admin.py startproject mysite
it will keep opening a file called django-admin.py you know, nothing else
"but the path is incorrect i don't have an application data folder in C:\Documents and Settings\Administrator\"
This would mean that your Python or Django installation is corrupted (probably due to reinstall Python).
Try go to square zero and reinstall both Python and Djangon on your computer. Also if it still does not work please describe how did you install both of them.
Related
I am a total newbie when it comes to django. However I have experience with python, I know how to install modules etc. I work on Win7 x64 with Python 2.7
Here is what I did:
Made sure Python environment variable is Set in %PATH%
installed django with pip install Django and checked afterwards if it installed (1.5.4)
added C:\Python27\Scripts to the environment variables (django-admin.py is there)
restarted cmd
enter django-admin.py help - no Error nothing, jumps to next line
enter django-admin.py startproject mysite - no Error, no Folder created, jumps to next line
enter django-admin.py gsfögjsdfüoisudhihdsf - no Error, nothing jumps to next line
did a pip uninstall Django and reinstalled it with pip install Django and tried started again at point 1
So now I have no idea what could be wrong. I even checked if the from django.core import management in the django-admin.py works - it does.
Any ideas?
Edit: Solved it by changing the .py associations. If you still encounter an error (like I did) go How to edit file associations
I am trying a python, django tutorial. It says type django-admin.py however I get 'command not found' with this.
Someone told me that the problem could be that django is not in your system path, what does that mean?
I am using ubuntu.
System path is an system environment variable that contains the path for some folders where the os will search for applications, scripts, etc.
In windows django-admin.py is in C:\Python\scripts, so if you have set the PYTHONPATH environment variable and added all the required python folder in that variable like C:\Python;C:\Python\Lib;C:\Python\scripts;C:\Python\Lib\site-packages, the os will automatically find django-admin.py when you will type the command django-admin.py startproject myproj on commandline.
same with linux, the django-admin.py is in /usr/bin/django-admin.py if you install django for the default python installation.
so, one way could be if you create a alias for that script so that you can run it from where ever you want.
i am using centos and what i did is i edited the /etc/bashrc and added
alias djangoadmin='/usr/bin/django-admin.py' and it works for me very well.
On Linux, check this official doc page: Link
On Windows, this one should do want you want: Link
If you installed Django from the Ubuntu repositories via apt-get or synaptic, the script will be simply django-admin (without the .py).
It worked when I did the poll tutorial in linux, but I'm doing it again in Windows 7, and it does nothing.
I already set the environmental variables, and set the file association to my python27.exe
When I run django-admin.py startproject mysite from the DOS command prompt, it executes, but it's showing me all the information (Like the options, etc) as though I typed the help option instead. It's not actually creating project files in my directory. I appreciate the help.
also, I tried the solution found here (it appears to be the exact same problem).
It did not work
django-admin.py is not working properly
I ran into the same problem.
Never having worked with Django before but having worked with Python 2.7 a fair bit, all on a windows 7 platform. I downloaded the latest version of Django and unpacked it on my desktop.
After mucking around a bit managed to get it to install itself. I found could not just follow the tutorial thats provided in the docs googled the problem and found this thread, now I was able to get it to work by doing the following things,
I work with a dos command window open. I navigate to the root of where I want the project file to be set up. I then ensure that the django_admin file has been editted as per wynston's instructions and then typed the following.
python c:\location of django_admin.py startproject projectname
and it executed beautifully.
*Thanks to wynston for the edit to the django_admin.py file.
Try to run python27 django-admin.py startproject mysite from the command line,maybe a different (older) python.exe executes the django-admin.py file. If there's a program associated to the .py files, things mixes up, and your path environment variable doesn't matter.
I suggest you to use virtualenv. When you use it, you should put the python.exe before every .py file you want to run, because the install of python will associate .py files to the installed python.exe, and will use that, whatever is in your path. :(
Change the first line of django-admin.py #!/usr/bin/env python to for example
#!D:\Program Files\Python\python.exe (Where you install your python.exe,that's my directory), it works.
Use python django-admin.py startproject mysite. That worked for me some time ago when I had the same issue.
The solution is simple in Windows:
1-Go to C: \ Python34 \ Scripts
2-Right click on django-admin.py
3-Select open with
4-Select default program
5-Select Laucher Python for Windows (Console)
6- Run the command in CMD Windows python django-admin.py startproject mysite
Great answers. But unfortunately it did not work for me. This is how I solved it
Opened django_admin.py as #wynston said. But the path at first line was already showing #!C:\ correctly. So did not had to change it
I had to put "..." around django-admin.py address. Navigated to the project directory in cmd.exe and ran this
python "C:\Users\ ......\Scripts\django-admin.py" startproject projectname
It worked only with the quotation marks. I am using Anaconda Python 2.7 64 bit, on Windows 7, 64 bit. Hope it helps
Just started trying to learn Python and Django today. Following their documentations I was able to install Python and Django and got them up and running. I'm running Apache 2.2 on on Windows 7 by the way.
I got to the part in the official tutorial that tells me to cd to the directory I want for my project and run this command
django-admin.py startproject mysite
However I can't just run that command as is. I need to run it like this
python c:\Python27\Scripts\django-admin.py startproject mysite
Am I suppose to type out the whole thing like this? Or is there some settings I miss that will let me run the .py file without the python C:\Python27\Scripts\ part in front?
If you want to just be able to type django-admin.py, two things need to be set up:
The directory containing it needs to be in your PATH.
You need to make sure that the .py extension is associated with the Python interpreter. This is normally done during the installation of Python.
How to set the PATH on Windows 7: http://geekswithblogs.net/renso/archive/2009/10/21/how-to-set-the-windows-path-in-windows-7.aspx
How to make sure .py is associated with Python: http://docs.python.org/faq/windows.html
Try running:
python django-admin.py startproject mysite
If that don't work, try adding C:\Python27\ to the command search path
I'm learning django and I did successfully start a site on Windows XP by following the tutorial.
However, on Windows 7 when I issued:
django-admin.py startproject mysite
python.exe was started and a window appeared to ask me to choose either python.exe or other program to open a file....
Did I do anything wrong or there are more tricks for windows 7?
That's already been reported to the django, see http://bugs.python.org/issue7936
And these's an solution:
open regedit and find python.exe like this
"C:\Python26\python.exe" "%1"
change it to
"C:\Python26\python.exe" "%1" %*
This is what worked for me:
I already had c:\python27 and c:\python27\Scripts in PATH.
Copy django-admin.py and django-admin-script.py from c:\python27\Scripts to your desired folder
with cmd go to that folder and run > django-admin startproject mysite
Note that if I doesn't type python windows just opens the django-admin.py in editor.
I had the same error when I ran django-admin.py on the command prompt. I couldn't create a projects.
I tried to run Regedit by using Find to Search python.exe and then adding %% but it was not sufficient.
I then added the necessary Path to the System PATH as shown below.
Open:
Control Panel -> System -> Advanced -> Environment Variables -> PATH.
Add to the PATH:
C:\Python27\python.exe;C:\Python27\Scripts;C:\Python27\Lib\site-packages\django\bin
It Work! Now I can Create Django Projects and applications Using Command on Windows 7.
In latest django(1.11.7 for now) , simple django-admin would work, instead of django-admin.py .
I had the same problem i followed django-admin.py startproject mysite not working well on windows 7
and found that the python files still associated with my text editor.
Changing the necessary registry keys fix the issue.
I also had the same problem but don't worry its simple to solve this problem, just add "C:\Users\Nik's\myenv\Scripts" to the enviroment veriables and its done.
The address may be differnt in your pc as it depends where you install it.
Change the first line of django-admin.py #!/usr/bin/env python to for example #!D:\Program Files\Python\python.exe (Where you install your python.exe,that's my directory); it works.
The solution is simple in Windows:
1-Go to C: \ Python34 \ Scripts
2-Right click on django-admin.py
3-Select open with
4-Select default program
5-Select Laucher Python for Windows (Console)
6- Run the command in CMD Windows python django-admin.py startproject mysite
In Windows 8.1, I faced the same problem. In my case when I tried to create my project, it would open the contents of the page in Internet Explorer window rather than creating the project folder. I became curious of what exactly was this django-manage.py. After searching, I got to django-admin.py file in the path C:\Python34\Scripts and I right clicked on it chose to open with default program of Launcher Python for Windows(Console).
Again I got back to the CMD and in my project directory I entered:
django-admin.py startproject mysite
And worked just fine.!!!
I have faced the same issue and when I ran the Python installer again and clicked on the repair option, it magically fixed everything for me. Now, I can run django-admin straight from CMD.
first of all make sure that python/Scripts is in your path
run "django-admin startproject mysite" instead of "django-admin.py startproject mysite"
I get the same problem for Windows 10. Here is how I resolve it:
I run the terminal CMD with administrator right. How to do that ? Right click on the terminal and click on Run as administrator.
I install django by doing: python -m pip install django. You can check that django is really installed by doing: python -m pip freeze. If you see django in the list, then django is installed.
Finally, I create my django project by doing: django-admin startproject project-name.
NB: For step 3, you don't need the terminal with administrator right.