How to open python scripts directly by typing in their name in terminal (Mac OS X)

Posted by Haffi112 on Super User See other posts from Super User or by Haffi112
Published on 2011-03-01T20:44:05Z Indexed on 2012/06/29 3:18 UTC
Read the original article Hit count: 533

Filed under:
|
|

I'm working on installing django and running it on my system.

I have a problem though, in this tutorial creating a project is explained by running the command

django-admin.py startproject mysite

My issue is that this doesn't work. I changed to the directory where django-admin.py is located and ran the command

chmod +x django-admin.py

with no results. I tried adding the directory with the file to my path without results. I ended up fixing my problem with this command

python /location/of/django-admin.py startproject mysite

which yielded the outcome I expected. My problem is: What do I need to change/configure such that command

django-admin.py startproject mysite

would be sufficient?

Here are some experiments:

21:09~/Desktop/HI/NSN/Polls > django-admin.py startproject mysite
-bash: django-admin.py: command not found
21:09~/Desktop/HI/NSN/Polls > ./django-admin.py startproject mysite
-bash: ./django-admin.py: No such file or directory
21:09~/Desktop/HI/NSN/Polls > python django-admin.py startproject mysite
python: can't open file 'django-admin.py': [Errno 2] No such file or directory
21:09~/Desktop/HI/NSN/Polls > /opt/local/lib/python2.4/site-packages/django/bin/django-admin.py startproject prufa1
-bash: /opt/local/lib/python2.4/site-packages/django/bin/django-admin.py: /opt/local/bin: bad interpreter: Permission denied
21:09~/Desktop/HI/NSN/Polls > sudo /opt/local/lib/python2.4/site-packages/django/bin/django-admin.py startproject prufa1Password:
sudo: unable to execute /opt/local/lib/python2.4/site-packages/django/bin/django-admin.py: Permission denied
21:09~/Desktop/HI/NSN/Polls > sudo /opt/local/lib/python2.4/site-packages/django/bin/django-admin.py startproject prufa1sudo: unable to execute /opt/local/lib/python2.4/site-packages/django/bin/django-admin.py: Permission denied
21:09~/Desktop/HI/NSN/Polls > python /opt/local/lib/python2.4/site-packages/django/bin/django-admin.py startproject prufa1
21:09~/Desktop/HI/NSN/Polls > ls
mysite prufa1

Final edit: The problem is solved, see Ian C's answer for the right solution. Thank you everyone for helping my out, this was very fast!

© Super User or respective owner

Related posts about osx-snow-leopard

Related posts about python