django newbie with an install problem - bad interpreter

811 views
Skip to first unread message

lorax

unread,
May 20, 2008, 8:23:17 AM5/20/08
to Django users
I've just got the keys to Django 0.96.2 on a semi-dedicated server at
WestHost. Largely spurred on by the receipt of the first of 4 Django
books. I fetched a copy of the download using wget and untarred the
file right from the command line on the server. I then attempted to
add django-admin.py to the server path and restarted the server. Then
I tried to execute the command django-admin.py startproject mysite.
That gave me an error:

-sh: /usr/local/Django-0.96.2/django/bin/django-admin.py: /usr/bin/
env: bad interpreter: No such file or directory

I thought my symlink might be bad so I tried executing the command
using the full path to django-admin.py which gave me the same message.
Since the files never touched a Windows machine could I still have a
hidden character in there? If so, how do I get rid of it? Or what else
might be the issue.

TIA Gregg

Karen Tracey

unread,
May 20, 2008, 8:54:53 AM5/20/08
to django...@googlegroups.com

django-admin.py is trying to run /usr/bin/env to launch python.  It sounds like your host does not have /usr/bin/env?  What happens if you try the command:

/usr/bin/env --help

from a command prompt?

Karen

Gregg Banse

unread,
May 20, 2008, 9:01:02 AM5/20/08
to django...@googlegroups.com
Hi Karen,
Thanks for the response.
 
The system didn't like that command. - No such file or directory.


 

lorax

unread,
May 20, 2008, 9:17:38 AM5/20/08
to Django users
BUT!

env --help DID work

Karen Tracey

unread,
May 20, 2008, 9:22:55 AM5/20/08
to django...@googlegroups.com
On Tue, May 20, 2008 at 9:17 AM, lorax <gregg...@gmail.com> wrote:

BUT!

env --help DID work

Hmm.  So env is in some non-standard place?  What does "which env" show?

You could patch your django-admin.py to point to where your host has put env.  It's a bit odd for it not to be in /usr/bin, though -- this is going to break plenty of python scripts that assume /usr/bin/env will be there.

Karen

lorax

unread,
May 20, 2008, 9:27:35 AM5/20/08
to Django users
Seems it's in /bin/env

On May 20, 9:22 am, "Karen Tracey" <kmtra...@gmail.com> wrote:

lorax

unread,
May 20, 2008, 9:29:57 AM5/20/08
to Django users
Re: break python scripts.

This is my first foray into Python so other than Django, I'm not sure
what I'd break. And I'm not sure what you mean by patch django-
admin.py to point to where env is.

Thanks for you help.

Marco Buttu

unread,
May 20, 2008, 9:30:47 AM5/20/08
to django...@googlegroups.com
On Tue, 2008-05-20 at 05:23 -0700, lorax wrote:

> I tried to execute the command django-admin.py startproject mysite.
> That gave me an error:
>
> -sh: /usr/local/Django-0.96.2/django/bin/django-admin.py: /usr/bin/
> env: bad interpreter: No such file or directory
>
> I thought my symlink might be bad so I tried executing the command
> using the full path to django-admin.py which gave me the same message.

You can try without use env:

python /usr/local/Django-0.96.2/django/bin/django-admin.py startproject
mysite

--
Marco Buttu

Karen Tracey

unread,
May 20, 2008, 9:37:45 AM5/20/08
to django...@googlegroups.com
On Tue, May 20, 2008 at 9:29 AM, lorax <gregg...@gmail.com> wrote:

Re: break python scripts.

This is my first foray into Python so other than Django, I'm not sure
what I'd break. And I'm not sure what you mean by patch django-
admin.py to point to where env is.

Thanks for you help.

re: patching django-admin

You could change the first line of django-admin.py from:

#!/usr/bin/env python

to

#!/bin/env python

Or, as Marco says you could preface the script name with 'python' and avoid the whole issue.  The first line is just trying to get the shell to find the appropriate python command to run in order to execute the script, if you run python directly the first line is ignored (since it's a python comment).

re: breaking python

I wasn't saying you would break anything, I was saying the hosting provider has caused things to break by putting env in a non-standard place.  Lots of python scripts use that first line, and apparently none of them will work on your hosting provider's setup because they've placed env in a non-standard location.

Karen
 

lorax

unread,
May 20, 2008, 9:39:07 AM5/20/08
to Django users
That worked!

So adding "python" to the front of the command seems to be the trick.
Perhaps I should add a symlink to point to where Python lives?

lorax

unread,
May 20, 2008, 9:41:43 AM5/20/08
to Django users
Re: non-std host setup

Ah.. got it. Thank you. So I can edit django-admin.py with PICO to
point to where they've located "env" and that should take care of the
issue too.

lorax

unread,
May 20, 2008, 9:51:27 AM5/20/08
to Django users
FYI - (sorry about all the posts)

I edited the django-admin.py file and changed the first line where it
calls for env.

Original: /usr/bin/env
Edited: /bin/env

Now it works just fine. Thank you both!
Reply all
Reply to author
Forward
0 new messages