I have followed this tutorial on Youtube.
First, I think everything was fine etc. but when I want so run the Server with: python manage.py runserver it doesn't work. I got the following error:
bash: /Applications/MAMP/Library/bin/python: No such file or directory
The manage.py file is there and I have tried it several times. I don't know what the problem can be. I have reinstalled python, home-brew, pip and virtualenv
It sounds like you don't have Python installed, or it isn't present in your PATH variables.
In command line try the following
python --version
You should expect to see
python x.x.x
If it isn't included in your PATH variables, you will receive
'python' is not recognized as an internal or external command,
operable program or batch file.
This can be fixed by going to the following
Right click This PC and select Advanced Properties
Click Environment Variables and select Path from the System variables
Click Edit and add Python. It should be at C:\PythonXX, though it would depend on your install directory
And adding Python
If Python is already installed
If Python is already installed, you aren't in the correct working directory. Could you please share your directory tree, including where manage.py is located.
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
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.
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).
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.