django-admin.py startproject mysite not working well on windows 7 - python
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.
Related
Do you know why Django ls might not show up in project directory?
I tried to use django-admin.py from your virtualenv virtual environment but the manage.py and other files do not get created. I tried using the ls command and nothing shows up in the project directory. I am using version 3 of Django and I ran it using powershell in adminstrator mode. Please help! Thank you very much, Josh
use something like this first make sure where your current working directory is using 'pwd' command and after that use this command 'django-admin startproject nameofyourproject .'
django for python set up issues
I'm not familiar with using command prompt and having trouble at the start of the django for python set up process which i'm reading here: https://docs.djangoproject.com/en/2.2/intro/tutorial01/ My problem appears to be the 'python' command doesn't work (please see my command prompt screen shot). I tried adding it into 'System variables' in the 'Environment Variables' as shown in the other screen shot. Is there something i have done incorrectly here? Also although i can get the create the initial project the only place i can create it is in the 'c:\Python\Lib\site-packages\django\bin' folder because i have to be looking at this folder in order to run the django-admin.py file. I think the second issue is related to the first issue though i.e. if the 'python' command worked i could just run 'python django-admin.py startproject mysite' while my directory path is set to where ever i want the project to be created. I expect i could simply move the mysite folder to where i want it but i feel i need to understand why this all isn't working as expected before moving on. Additional: I've now tried creating a virtual environment as suggested in the comments. Running 'pip install virtualenvwrapper-win' appears to have worked. Running 'mkvirtualenv myproject' has not worked. It says 'C:\Users\mogwa\Envs is not a directory although i can view this path so it is actually there. https://docs.djangoproject.com/en/2.2/howto/windows/
Create Python virtual envoirement (virtual env, venv). Wait a little. for Linux/GNU: python -m venv venv for Windows: (If not python in windows paths) py -m venv venv Activate your new python envoirement for Linux/GNU: source venv/bin/activate for Windows: (Option 1) source venv/Scripts/activate for Windows: (Option 2) .\venv\Scripts\activate.bat Install django over pip (You should see (venv)) pip install Django Start new Django Project: django-admin startproject projectname For Start new Django App: django-admin startapp appname
django-admin.py startproject asks to chose default program
When trying to start a project with django using : django-admin.py startproject a pop up window opens asking to choose a default program to use. The two main programs it shows are : Visual studio and Notepad. I have already set the python in 'PATH' and same with the pip which i used to install django. What should I do to fix that? Thanks.
run python <PATH>/django-admin.py startproject your system is not configured to run .py files. read here
django-admin.py startproject mysite is not doing anything
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
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.