Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > cannot execute binary file (Python 3.0.1)

Reply
Thread Tools

cannot execute binary file (Python 3.0.1)

 
 
cf29
Guest
Posts: n/a
 
      03-01-2009
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
 
Reply With Quote
 
 
 
 
Chris Rebert
Guest
Posts: n/a
 
      03-01-2009
On Sun, Mar 1, 2009 at 12:04 AM, cf29 <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
 
cf29
Guest
Posts: n/a
 
      03-01-2009
On Mar 1, 11:14*am, Chris Rebert <(E-Mail Removed)> 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/
 
Reply With Quote
 
Ned Deily
Guest
Posts: n/a
 
      03-01-2009
In article
<(E-Mail Removed)>,
cf29 <(E-Mail Removed)> 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,
http://www.velocityreviews.com/forums/(E-Mail Removed)

 
Reply With Quote
 
cf29
Guest
Posts: n/a
 
      03-01-2009
On Mar 1, 12:52*pm, Ned Deily <(E-Mail Removed)> 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,
> *(E-Mail Removed)



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/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie: working with binary files/extract png from a binary file Jim Ruby 6 12-24-2013 08:09 AM
writing binary file (ios::binary) Ron Eggler C++ 9 04-28-2008 08:20 AM
Execute binary code citronelu@yahoo.com Python 20 01-11-2007 11:53 AM
how to decompile a c/c++ binary execute file ? P1u70 C++ 2 12-26-2006 01:27 PM
Can i execute aspx file in my asp pag with server.execute method(sorry) Savas Ates ASP General 1 08-17-2004 04:52 PM



Advertisments