Bad Interpreter

Discussion in 'Python' started by RajaSrinivasan@hotmail.com, Jan 3, 2005.

  1. Guest

    I have seen some previous messages about such a problem. I have this
    problem but it is not clear what the solution really was.

    I am running FC2, python 2.3.3

    the script i have sock.py runs if i say something like :

    python sock.py

    but ./sock.py results in a :bad interpreter error
    how do i troubleshoot something like this?

    regards
     
    , Jan 3, 2005
    #1
    1. Advertising

  2. <> wrote in message
    news:...
    > I have seen some previous messages about such a problem. I have this
    > problem but it is not clear what the solution really was.
    >
    > I am running FC2, python 2.3.3
    >
    > the script i have sock.py runs if i say something like :
    >
    > python sock.py
    >
    > but ./sock.py results in a :bad interpreter error
    > how do i troubleshoot something like this?
    >
    > regards
    >


    What does the first line of your script look like? It needs to be pointing
    to the python interpreter binary, which you can locate with:

    which python

    (on the command line). Check and make sure it is. If it is and you are
    still getting this problem, post some code and the complete error.

    HTH.
     
    Richards Noah \(IFR LIT MET\), Jan 3, 2005
    #2
    1. Advertising

  3. Craig Ringer Guest

    On Mon, 2005-01-03 at 12:24 -0800, wrote:
    > I have seen some previous messages about such a problem. I have this
    > problem but it is not clear what the solution really was.
    >
    > I am running FC2, python 2.3.3
    >
    > the script i have sock.py runs if i say something like :
    >
    > python sock.py
    >
    > but ./sock.py results in a :bad interpreter error
    > how do i troubleshoot something like this?


    You probably have Windows-style line endings in the file. The kernel
    sees the ^M at the end of the line and gets all confused.

    --
    Craig Ringer
     
    Craig Ringer, Jan 3, 2005
    #3
  4. On Mon, 03 Jan 2005 12:24:09 -0800, RajaSrinivasan wrote:

    > I have seen some previous messages about such a problem. I have this
    > problem but it is not clear what the solution really was.
    >
    > I am running FC2, python 2.3.3
    >
    > the script i have sock.py runs if i say something like :
    >
    > python sock.py
    >
    > but ./sock.py results in a :bad interpreter error
    > how do i troubleshoot something like this?
    >


    Check the first line of your script - it should set the path to the Python
    interpreter. It should look something like this:
    #!/usr/bin/python

    or
    #!/usr/bin/env python

    which doesn't explicitly set the path to the interpreter, but checks the
    environment variable called python for that path. If your python
    executable lives somewhere the first line or the environment variable
    doesn't point to, you'll need to correct that.

    --
    Christopher

    OutOfSigError
     
    Christopher Koppler, Jan 3, 2005
    #4
  5. Simon John Guest

    wrote:

    > the script i have sock.py runs if i say something like :
    >
    > python sock.py
    >
    > but ./sock.py results in a :bad interpreter error
    > how do i troubleshoot something like this?


    sounds like you've been editting the script on a windows machine, and
    it's inserted it's evil linefeeds.

    on the unix machine run 'dos2unix sock.py', or load sock.py into vi and
    remove the ^M characters
     
    Simon John, Jan 3, 2005
    #5
  6. Guest

    sounds like it. vi sock.py shows '$' at the end of each line.

    however when i went to a unix machine and recreated the file, the
    problem went away.

    thanks for all the help

    regards
     
    , Jan 4, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Goblin
    Replies:
    1
    Views:
    8,500
  2. BaBS

    Bad interpreter

    BaBS, May 26, 2004, in forum: Python
    Replies:
    10
    Views:
    662
  3. Replies:
    3
    Views:
    779
    Ziga Seilnacht
    Jan 3, 2007
  4. rantingrick
    Replies:
    44
    Views:
    1,274
    Peter Pearson
    Jul 13, 2010
  5. Jordi Bunster

    Bad interpreter

    Jordi Bunster, Jan 19, 2005, in forum: Ruby
    Replies:
    8
    Views:
    203
    Jordi Bunster
    Jan 20, 2005
Loading...

Share This Page