I have installed django 1.6.4 on my windows 7 (32-bit) machine, I'm using python 2.7.6
But when i started to create my project by using following command:
C:\django-admin.py startproject mysite
it doesn't create any folder named mysite under my current directory, instead it just simply runs the django-admin.py script, in fact no matter what i type after django-admin.py command i get the output of django-admin.py script on the command prompt.
C:\django-admin.py startproject mysite
C:\django-admin.py abcdefghi
both of the above commands just simply runs the django-admin.py script and does nothing else.
I checked online but i couldn't seem to find out the actual problem.
I have set all the environment variables of python and of django
Path= C:\Python27\;C:\Python27\Scripts
According to this :
https://docs.djangoproject.com/en/dev/1.6/django-admin/
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.
Related
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
First timer here with Django and I am running into some issues trying to start the site with the Windows command prompt django-admin startproject mysite
My pip install worked as I can import the module and check the Django version. I am also running Python version 3.6...
>>> import django
>>> print(django.get_version())
2.0.4
I also created a directory on my windows machine so my windows command prompt looks like this:
C:\Users\b\Documents\Python\Django>django-admin startproject mysite
But I am getting an error 'django-admin' is not a recognized as an internal or external command, operable program or batch file.'
Any tips to try??? Thanks
Add in the PATH for Django-admin
Open:
Control Panel -> System -> Advanced -> Environment Variables -> PATH.
Click new as shown above and then find in your Windows machine where the django-admin files live in the hidden directory for the Python SCRIPTS.
On my machine its here:
C:\Users\AppData\Local\Programs\Python\Python36-32\Scripts
Enter in PATH and your directory as shown below, then viola it should work
It looks like your django command utility is not registered in your systems path (the environment variable PATH in your windows system).
Have you looked into this post ? There are some pointers to get your machine up and running.
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).
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.
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.