Bouncing Python Application in Mac Dock when Accessing URLs with py-appscript - python

This has been a recurring, strange issue for me when accessing URLs using py-appscript, first in Safari and now in Chrome.
Whenever I run the script command to get the current URL in the terminal, for example,
appscript.app("Google Chrome").windows.active_tab.URL()
a bouncing instance of the "Python" application appears in the Dock. I have verified that this "Python" application is found in:
/Library/Frameworks/Python.framework/Versions/2.6/Resources
How do I get the current URL without this thing popping up?

The background on this problem is explained here by the author of appscript. Assuming you are on OS X 10.5 or higher, the solution is to use a Python that has been built using a minimum deployment target of 10.5 or higher. From the path you supplied, it appears likely you are using a Python 2.6 from a python.org installer. Traditionally, python.org Pythons are built to run on multiple versions from 10.3 on up and so appscript running under it will show this problem. Starting with Python 2.7 (and additionally soon with Python 3.2), python.org is providing a second installer variant, one that only runs on OS X 10.6 or higher. Those variants should not have the bouncing icon problem. Other options are to install a Python 2.6 using MacPorts, Fink, or HomeBrew or build it yourself (a little tricky to get all the batteries included). Or, if you are on OS X 10.6, you can use the Python 2.6 supplied by Apple in /usr/bin.

Related

Cannot get python IDLE 2.7, 3.3 to run - OS X

I am running a MacBook Pro with 8gb of memory and a 2.5GHz processor. I run OS X Mavericks, but this problem has happened on other operating systems as well. when I try to open the editor, or even open a python file, this happens:
This has been a problem since I got into python. I have tried as many versions as I can, and the same screen pops up. Please help
I recently also upgraded a friends iMac to OS X 10.9 Mavericks and her Python to 2.7.6. If you mount the python-2.7.6-macosx10.6.dmg disk image there's a text file named ReadMe.txt. If you ahem, actually read it, right near the beginning it says:
**** IMPORTANT ****
Update your version of Tcl/Tk to use IDLE or other Tk applications
To use IDLE or other programs that use the Tkinter graphical user
interface toolkit, you may need to install a newer third-party version
of the Tcl/Tk frameworks. Visit
http://www.python.org/download/mac/tcltk/ for current information
about supported and recommended versions of Tcl/Tk for this version of
Python and of Mac OS X.
Here's what http://www.python.org/download/mac/tcltk currently looks like (my highlighting):
To summarize: You need to download and install ActiveTcl 8.5.15.1 (which is mislabeled ActiveTcl 8.5.15.0) from ActiveState's webpage. After doing that you should be able to run IDLE:
I haven't actually tried to do it yet, but from what I read it sounds like the same process applies to Python 3.3.3 and its IDLE app.
I was having the exact same problem.
I was finally able to install Python (and IDLE) via MacPorts by also installing a package called "pyXX-tkinter" -- where XX is the version, e.g. py34-tkinter for Python 3.4.

installing IPython with two versions of Python (Windows)

Is it possible to have IPython (0.12) installed on the same
system with two different versions of Python (v 2.7 and 3.2)? Currently I have both versions of Python running happily on my system.
I am using two machines, one with Windows 7 64-bit, the other XP SP2 32-bit, and both have Python 2.7.2 and 3.2 installed. I have been using IPython with Python 2.7 w/o any problems for a while on both.
Now I would like to have 3.2 available too with IPython, but when I try to run the binary windows IPython installer I get this error toward the end of the install:
*** run_installscript: internal error 0xFFFFFFFF ***
and no shortcuts/entries into Start Menu etc are created.
(I ran the install as adminstrator under Win 7) I am running into the same problem with XP and Win 7.
After poking around the net and SO for a while I saw references for
getting setuptools. Unfortunately, there's no version for Python 3.x
but it was suggested to use distribute.py instead which I ran and
installed. I am not sure how to proceed next. And I'm not even sure it
is possible to do this (though I think it is :)
Any suggestions?
UPDATE: There was a problem with import readline not working with Python 3.2.3, but I was able to fix it by downloading pyreadline-2.0-dev1.win32.exe which works with Python 3.2.3 .. the above problem remains unfortunately.
Ok, here's my solution to get IPython 0.12.1 to work with both Python ver
2.7.x and 3.2.x on the same system (ie. under Windows 7 64 bit and XP SP2 32 bit). It's not
perfect, but works, and hopefully will help others. Where I am showing directories they refer to XP (but should be adjusted accordingly for Windows 7)
Steps for both:
Install both versions of Python via the binary windows installer provided at
Python.org
Install this version of pyreadline pyreadline-2.0-dev1.win32.exe which works
for both versions of Python (I could not get the widely available version 1.7 to work with Python 3.2.x)
I am not sure if distribute.py is necessary, I'd skip it on the
first try.
Download ipython-0.12.1.zip file and extract it. Place it under your Programs directory and cd into it (I'll call this the ipython_dir) [I tried the binary installer numerous times without success]
For Python 3.2 (easier)
In the ipython_dir:
c:\python32\pyton.exe setup.py install
will create ipython3.exe in c:\python32\Scripts that can be used to
fire up iPython
For Python 2.7 (a bit odd)
The above method failed. However, it is possible to start IPython from the ipython_dir with
c:\python27\python.exe ipython.py
I can't explain why this is so, but since I use Console2 I can hide
these two ways of starting IPython.
Summary:
To start IPython with v 2.7.x of Python:
c:\python27\python.exe "C:\Program Files..\ipython_dir\ipython.py"
To start IPython with v 3.2.x of Python:
c:\python32\Scripts\python3.exe
That was a lot of work and took most of the day, so I hope posting the steps above
will save someone else a lot of time (and help me remember what I have to do next time I struggle with this)
Thanks everyone for their suggestions.
Addendum: None of the above resulted in shortcuts or entries in the Start/Program Menus. Shortcuts can be created manually, or in my case aren't necessary since I'm using a special shell (Console2) to run IPython.
The first question in the iPython FAQ titled "Running IPython against multiple versions of Python" may help.

Python 3.0 - Idle wont open. It just bounces in the dock

Python/Unix noob. On Mac OSX.
Been running Python 2.7.2 for a few weeks, along with Idle app. No problems.
Today I just installed Python3.0 along side 2.7 - tested both and can still be ran via Terminal.
Now when I open Idle for 2.7, it opens just fine. But when I open the new Idle app within the Python3.0 folder, the app just bounces in the doc and never opens.
The error from Console is as follows:
12/2/11 11:57:13.612 PM com.apple.launchd.peruser.501:
([0x0-0x38038].org.python.IDLE[313])
posix_spawn("/Applications/Python-3.0/Mac/IDLE/IDLE.app/Contents/MacOS/IDLE", ...):
No such file or directory
How do I get Idle to open for Python3.0?
Do not use Python 3.0. The initial releases of Python 3 were somewhat experimental and had a number of serious problems that have been fixed in subsequent releases. The fixed problems include the one you're seeing which I believe was covered by Issue5196. The current release of Python 3 is 3.2.2 and is considered production-ready. You can find installers for Mac OS X here. There are two installers depending on which version of OS X you are running. If on OS X 10.6 (Snow Leopard) or 10.7 (Lion), pay particular attention to the cautions here about also installing the current version of ActiveState Tcl/Tk to be used instead of the buggy Tcl/Tk 8.5 shipped by Apple in those systems.

Building binary python distributions for multiple OS X versions

I am attempting to build a python application with binary modules on OS X. I want to build versions for Snow Leopard and Leopard from Lion. I have XCode 4 installed with the 10.5 and 10.6 sdks and have been attempting to build using the MACOSX_DEPLOYMENT_TARGET flag set to 10.6. I receive an error from distutils complaining that python was built with a different deployment target.
I tried building a separate python binary with the deployment target set to 10.6 and then used virtualenv to try to build from that, but virtualenv expected a lib directory under the base env directory that was not there.
I am a total newb at developing on Mac and not even sure if what I want to do is possible. Am I going to have to break down and have someone still running Snow Leopard build my distributions?
I really appreciate any assistance.
The system Pythons shipped by Apple in OS X 10.7 are built for 10.7 only. The simplest solution is to download the most recent Python 2.7 or 3.2 64-bit/32-bit installer from python.org and use it since it is a universal binary that will run on either 10.6 or 10.7. If you are making an app bundle, you'll need to install a copy of py2app for it and any other 3rd-party packages like Distribute (aka easy_install) or pip.
I found the solution, go into your /System/Library/Frameworks/Python.framework/Versions/2.7/lib/distutils/sysconfig.py
Goto line 408 that says "raise DistutilsPlatformError" and add a '#' to comment out that line of code... This will "unleash the python"
You are basically telling python "don't worry its not 10.7, I know" there could be some crashes as a result but I think otherwise. My very complex python applicaiton now compiles on MacOSX 10.8 with no troubles and it seems to do the job, QA still has to test it though.

Netbeans not allowing Python 2.6 as default platform (forcing Jython2.5)

I am trying to get Netbeans python to run with the default python platform set to Python 2.6.1 (my system python), so in Netbeans I do the following:
Tools -> Python Platform
Set Python 2.6.1 to 'default'
However, it seems impossible to make this stick. Whenever I restart Netbeans it's back to Jython 2.5 again.
Moreover, I can obviously autodetect and find Python 2.6.1, but whenever I make it "Default", Netbeans still runs with Jython 2.5 in that very session. (I know this because when I import sys and do a sys.path it only has Jython library dirs). And when I remove Jython I get the error:
"Selected project has broken python platform : default => bind to an existing python platform in project's properties".
I have tried this is 6.5 and 6.7. And I still get the same behavior. Furthermore, I know my system python works because I can use the python interpreter.
Looks like http://netbeans.org/bugzilla/show_bug.cgi?id=180693 which provides a clumsy and non persistent workaround.
This needs heavy complaining on the netbean bug tracker imo.
Might be worth logging a bug with Netbeans about the first bit of behaviour you described - I can confirm similar (although strangely not identical) symptoms on my system.
I tried this with Python 2.6.2 / Netbeans 6.5.1
NetBeans IDE 6.5.1 (Build 200903060201)
Java: 1.6.0_01; Java HotSpot(TM) Client VM 1.6.0_01-b06
System: Windows XP version 5.1 running on x86; Cp1252; en_GB (nb)
And my default Python platform also doesn't seem to stick: I restart and the default is back to "Jython 2.5b0+"
However, when I create a new Python project: the drop-down on the wizard is correctly set to 'Python 2.6.2": furthermore, when I created a new module like this:
import sys
print(sys.path)
It reports back correctly:
...'d:\\python26\\DLLs', 'd:\\python26\\lib'...
Maybe this is due to something about the slightly different Python platform versions - dunno?

Categories

Resources