cannot execute binary file (Python 3.0.1)

Discussion in 'Python' started by cf29, Mar 1, 2009.

  1. cf29

    cf29 Guest

    Greetings,
    On Mac OS 10.5.6, I updated Python to version 3.0.1.
    When I want to run a py file, I get an error:
    xxx:~ xxx$ cd '/Users/xxx/Documents/programmingPractice/' && '/usr/
    local/bin/python' '/Users/xxx/Documents/programmingPractice/
    python_file.py' && echo Exit status: $? && exit 1
    -bash: /usr/local/bin/python: cannot execute binary file

    This wasn't an issue with Python 2.6, please let me know how to solve
    this problem.
    Best regards
    Charly
     
    cf29, Mar 1, 2009
    #1
    1. Advertising

  2. cf29

    Chris Rebert Guest

    On Sun, Mar 1, 2009 at 12:04 AM, cf29 <> wrote:
    > Greetings,
    > On Mac OS 10.5.6, I updated Python to version 3.0.1.
    > When I want to run a py file, I get an error:
    > xxx:~ xxx$ cd '/Users/xxx/Documents/programmingPractice/' && '/usr/
    > local/bin/python'  '/Users/xxx/Documents/programmingPractice/
    > python_file.py'  && echo Exit status: $? && exit 1
    > -bash: /usr/local/bin/python: cannot execute binary file
    >
    > This wasn't an issue with Python 2.6, please let me know how to solve
    > this problem.


    Detailing exactly how you upgraded Python would help immensely.

    Cheers,
    Chris

    --
    Follow the path of the Iguana...
    http://rebertia.com
     
    Chris Rebert, Mar 1, 2009
    #2
    1. Advertising

  3. cf29

    cf29 Guest

    On Mar 1, 11:14 am, Chris Rebert <> wrote:
    > Detailing exactly how you upgraded Python would help immensely.
    >
    > Cheers,
    > Chris


    Thanks for your answer.
    I installed the package in python-3.0.1-macosx2009-02-14.dmg
    (downloaded from http://www.python.org/download/releases/3.0.1/) and
    runed the Update Shell Profile.command situated in the Python 3.0
    folder.

    If I type python in the Terminal, it says: Python 3.0.1 (r301:69597,
    Feb 14 2009, 19:03:52). So it seems that it is working properly.
    If I use the Terminal and type: python myfile.py, it works as
    expected.
    The issue is when I want to run py file either with Python
    Launcher.app or directly from BBEdit (the text editor i use). I get
    the "cannot execute binary file" error.

    In /usr/local/bin/ the python symbolic link is connected to Python v3

    Charly http://cf29.com/
     
    cf29, Mar 1, 2009
    #3
  4. cf29

    Ned Deily Guest

    In article
    <>,
    cf29 <> wrote:
    > On Mac OS 10.5.6, I updated Python to version 3.0.1.
    > When I want to run a py file, I get an error:
    > xxx:~ xxx$ cd '/Users/xxx/Documents/programmingPractice/' && '/usr/
    > local/bin/python' '/Users/xxx/Documents/programmingPractice/
    > python_file.py' && echo Exit status: $? && exit 1
    > -bash: /usr/local/bin/python: cannot execute binary file
    >
    > This wasn't an issue with Python 2.6, please let me know how to solve
    > this problem.


    It appears you are trying to run a python script by double-clicking on
    it and that Python Launcher.app is the default application associated
    with .py files. The default setting in Python Launcher is to use the
    python linked to /use/local/bin/pythonw. By default, the OS X 3.0.1
    installer does not install or modify the links in /usr/local/bin/,
    unlike 2.x installers. That is a problem for Python Launcher. Here are
    a few options, assuming you used the 3.0.1 python.org installer:

    1. You can start up the installer again, choose Customize, and then
    select and install the "UNIX command-line tools" package.
    /usr/local/bin/pythonw will now point out at python 3.0.1 rather than
    python 2.6.

    2. Launch Python Launcher and change its Preferences. Python Launcher
    should be in the /Applications/Python 3.0 folder. Select Preferences
    and in the Interpreter field enter the full path to python3.0, which is:
    /Library/Frameworks/Python.framework/Versions/3.0/bin/python3.0

    3. Use IDLE instead of Python Launcher to run scripts. Just launch IDLE
    (it's also in /Applications/Python 3.0) and open the script file from
    IDLE's menu bar. Or drag-drop the script onto the IDLE icon in the
    Dock. If you want to be able to double-click on the file in the Finder,
    you'll need to change the default application associated with .py files.
    In a Finder window or the desktop select your python script file but
    don't double-click it. Instead, choose the FInder's "Get Info" command
    and in the resulting Info window choose IDLE 3.0.1 in the "Open with"
    list. To open all .py files with IDLE, if necessary click on the
    padlock in the lower right-hand corner of the Info window to
    authenticate, then click on the Change All.. button.

    4. Run your scripts in a terminal window using python3.0 from the shell
    command line. You can use the above path to execute python; it might
    help to create a shell alias for it. Or double-click on the Update
    Shell Profile command in /Applications/Python 3.0 to cause python3.0 to
    be added to your shell PATH and then just type python3.0.

    I would recommend either (or both) of the last two approaches. You'll
    be better off avoiding Python Launcher.

    --
    Ned Deily,
     
    Ned Deily, Mar 1, 2009
    #4
  5. cf29

    cf29 Guest

    On Mar 1, 12:52 pm, Ned Deily <> wrote:
    > It appears you are trying to run a python script by double-clicking on
    > it and that Python Launcher.app is the default application associated
    > with .py files.  The default setting in Python Launcher is to use the
    > python linked to /use/local/bin/pythonw.  By default, the OS X 3.0.1
    > installer does not install or modify the links in /usr/local/bin/,
    > unlike 2.x installers.  That is a problem for Python Launcher.  Here are
    > a few options, assuming you used the 3.0.1 python.org installer:
    >
    > 1. You can start up the installer again, choose Customize, and then
    > select and install the "UNIX command-line tools" package.  
    > /usr/local/bin/pythonw will now point out at python 3.0.1 rather than
    > python 2.6.
    >
    > --
    >  Ned Deily,
    >  



    Thank you Ned! The 1. did the trick.
    Actually I was using the open menu of Python Launcher to open my
    files. And now it works fine.
    Usually I use to run python scripts from BBEdit itself and this is now
    working as expected.
    What a great place to find answers! Thanks again.
    Charly
    http://cf29.com/
     
    cf29, Mar 1, 2009
    #5
    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.

Share This Page