cannot execute binary file (Python 3.0.1)

C

cf29

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
 
C

Chris Rebert

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
 
C

cf29

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/
 
N

Ned Deily

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.
 
C

cf29

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.


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/
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top