django-admin.py startproject mysite is not doing anything - python

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

Related

Django is not accepting arguments in Windows

I have installed django on my windows vista computer and can add the django library to a python script, but cannot seem to ge teh following to work correctly from the command line:
django-admin.py startproject mysite
When I try to run this or the help command I always get the default message that shows all the commands as if I did not send it the second argument.
Any ideas on how to resolve this issue?
try
python django-admin.py startproject mysite
you may cd to the dir which the django-admin.py in
The biggest headache I've run into with developing on Windows is path issues. I use virtualenv and David Marble's port of virtualenvwrapper As such, I fully qualify the path to django-admin.py. Of course, the virtualenv's site-packages could get added to my PATH, but I find it just as easy to just paste in the path.
Try fully qualifying the path to django-admin.py and see if that gets you going.
If python variable environment is set you should try something like
python Path\to\django\installation\bin\django-admin.py startproject mysite
FYI, I figured out the issue based on another thread I found here:
Windows is not passing command line arguments to Python programs executed from the shell
The issue was about how the registry was handling my calls to admin.py and the fact that it was dropping the arguments I passed.
Hope this helps others who run into this issue.

Why does django open with pype?

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.

How to make Python knows the path to look for .py files?

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

django-admin.py startproject mysite not working well on windows 7

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.

How to integrate Django and Cygwin?

I have a Windows box with cygwin, python and django installed.
Now I want to run django-admin, but when I do I get the error:
$ django-admin.py
c:\Python26\python.exe: can't open file '/usr/bin/django-admin.py': [Errno 2] No such file or directory
From here
For Windows users, who do not have symlinking functionality available, you can copy django-admin.py to a location on your existing path or edit the PATH settings (under Settings - Control Panel - System - Advanced - Environment...) to point to its installed location.
hope this helps
I just ran into the exact same problem. I've found that if you already have the windows version of python installed, it seems to get priority over the cygwin version. I solved the problem by editing /etc/profile and changed:
PATH=/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:$PATH
...to:
PATH=/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:
...which I think stops cygwin from adding the normal windows path. Once you've got that working, download django into some directory, move into that directory and type:
python setup.py install
I was having problems to begin with because I had omitted the 'python' bit at the start
As for the step on how to start your django in cygwin
first open your windows command prompt
then register the python environment by doing this:
Path %path%;C:\Python27;C:\Python27\Scripts
then now go to the installation folder of your cygwin
cd C:\cygwin
then run the cygwin.bat like this:
C:\cygwin>cygwin.bat <enter>
then cygwin will open, and type python to see if it now working
$ python
Voila we are done!
Sort of sounds like the windows version of Python is trying to run instead of the cygwin one. What happens if you type this:
$ python django-admin.py
Here I'm assuming
$ which python
Finds the cygwin version of python (which will be something like /usr/bin/python).
You may also try (temporarily) uninstalling the windows version of python and use only cygwin.
Help us help you. Is there a reason why you are running the windows python interpreter (c:\Python26\python.exe) as oppose to the cygwin python interpreter (/usr/bin/python.exe)? That could be your problem. So to troubleshoot that, you might consider removing the windows native interpreter or simply making sure the cygwin path is listed before the c:\Python26 path in the windows global PATH variable.
Add the location of your django/bin folder (or wherever else you keep django-admin.py) to your PYTHONPATH environment variable.
Like Brian mentioned you are running the Windows version of Python which won't work with the Cygwin installation.
A word of warning. When I first started using Django, I tried installing it in Cygwin and had a variety of problems and ended up switching to the regular Windows version of Python. Unfortunately, I didn't document all my issues, but I remember some of them had to do with the database libraries. Anyway, that was a few months ago when I knew less about Django than I do now. Maybe the problems I ran into have been solved and perhaps now that I know more I could get it to work, but running Django on Cygwin does seem to be the road less traveled. Good luck. :)
Just copy the django-admin.py to the current location you are working on for e.g
on Cygwin:
<root>/projects/
on your windows directory it will look like this:
C:\cygwin\home\<your computer name>\projects\
once you copy the file, you can create your project by typing this command:
$ python django-admin.py startproject mysite
and that's all - you have completed your first project using the Cygwin linux-like environment.
Add two lines to .bash_profile and .bashrc files (view their difference here). You can find them in C:\cygwin\home\[username]:
export PATH=$PATH:/cygdrive/c/python2.7
export PYTHONPATH=$PYTHONPATH:/cygdrive/c/python2.7/Lib/site-packages
Hope this helps

Categories

Resources