I cannot tell webkit2png where to find the libraries (they are installed!)
It’s related to this:
Does anyone know how to tell AppleScript to use libraries not beeing in its “do shell”-path environment???
I’ve had this problem once using nmap or lynx (don’t know which one anymore) binaries. But I was able to build an application bundle and placed the libs within the bundle, configured as needed and it worked.
But this was not Python. And I am not so much familiar with Python on the Mac as I wanted to be.
.tom
Model: Mac-Mini 1.42 G4 80/250 GB HD 1GB RAM
AppleScript: Current
Browser: Firefox 2.0.0.1
Operating System: Mac OS X (10.4.8)
It says that Python 2.4 is required, but Mac OS X seems to come with 2.3.5 (on my machine with Mac OS X 10.4.8 installed, at least). Did you install a newer version yourself and adjust your $PATH to that instead?
Check/post the results for these (run the first two from the command line):
which python
echo $PATH
do shell script "which python"
do shell script "echo $PATH"
The solution here, if I’m understanding the problem correctly, is to always use full path to executable when using do shell script.
So the problem can be reduced to the point, how to change AppleScript’s environment $PATH defaults. And, if we want to be userfriendly, how to change them using AppleScript itself?
set py_text to "import sys
print sys.path"
set py_com to ReplaceText(py_text, return, ASCII character 10)
do shell script "python -c " & quoted form of py_com
--
on ReplaceText(t, s, r)
set utid to AppleScript's text item delimiters
set AppleScript's text item delimiters to s
set temp_list to text items of t
set AppleScript's text item delimiters to r
set temp_text to temp_list as string
set AppleScript's text item delimiters to utid
return temp_text
end ReplaceText
As Bruce wrote, I think, is that your updated version of Python is not running in the ‘do shell script’. With ‘do shell script’ you get the default path which is the path to your old version of python. So, you want to change things so that your ‘do shell script’ runs the new Python.
What I did was match them exactly by adding a ~/.MacOSX/environment.plist file. But first as Bruce wrote, check your paths. In Terminal and Script Editor:
echo $PATH
What I did was just copy the PATH value from Terminal and enter it in the environment.plist file. So I would copy the result to:
where “/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/kel”.
Note that /usr/local/bin/ contains a link to the updated version of python. This path I got from Terminal is updated because I add a ~/.profile file for bash. First, I would check if you have /usr/local/bin/python and see if the installer created the link.
This is confusing, so if you plan to change the PATH and need more help write back.
Edited: I forgot to mention that after creating or editing the environment.plist file, you need to relogin. the os reads the updated environment varibles from environment.plist at login.