OSX: pyXML extensions work only thru command-line hackery

Bug #168440 reported by Bug Importer
0
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Undecided
Michael Wybrow

Bug Description

Double-clicking Inkscape, I cannot use extensions. "The inkex.py module
requires PyXML." I downloaded & installed pyXML. Same error message.

However, if I launch from the terminal (after X11 starts) by:
[~]$ export DISPLAY=0:0
[~]$ export
PATH=/Library/Frameworks/Python.framework/Versions/Current/bin:$PATH
[~]$ /Applications/Inkscape.app/Contents/MacOS/Inkscape

then extensions work fine.

Hope this helps!

Tags: osx
Revision history for this message
JiHO (jiho) wrote :

Originator: NO

Hi,

This is very strange. Could you please give me a little more info:
- copy/paste here the output of these commands in a Terminal please
  echo $PATH
  which python
- how did you install pyXML? trough Fink, DarwinPorts? Did you download
the source and compiled it yourself or did you used the precompiled
packages which come with the release version?
Thank you in advance,
JiHO

Revision history for this message
Krolco (krolco) wrote :

Originator: NO

I had the exact same problem.

Here's a bit more info, which hopefully should make this more clear.
I am using a "stock" OSX 10.4.9, which by default includes Python 2.3.5.

I used Inkscape 0.45.1-1 Tiger Universal .DMG to obtain Inkscape.

I tried doing a "Save As" to "DXF", and I got the same error message ("The
inkex.py module requires PyXML").

So I downloaded PyXML 0.84 .dmg, but that requires Python 2.4 or higher.

So I downloaded python-2.4.4-macosx2006-10-18.dmg from pythonmac.org to
install python 2.4.4, which by default goes into /usr/local (instead of
just /usr).

Then I installed PyXML, using all the "default" options. So far so good.

Now, I had already modified my .bash_login file to include /usr/local/bin
in my path. After install, Python 2.4.4 seems to be working fine.

Here is my 'echo $PATH':

/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/bin:/sbin:/usr/bin:/usr/sbin

Here is my 'which python':

/Library/Frameworks/Python.framework/Versions/Current/bin/python

Both of these were echoed from Terminal.

Now, I discovered that the paths were different between Terminal and
xterm... it looks to me like xterm doesn't honor the .bash_login file.

 So I copied some relevant path stuff to .bashrc, and restarted X11. Here
are the same commands run from the X11 command path now:

'echo $PATH':

/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/X11R6/bin

'which python':

/Library/Frameworks/Python.framework/Versions/Current/bin/python

Now, even after these changes, when I run Inkscape 0.45.1-1 and try to
"Save As" to .DXF, I still get the same error.

That suggests to me that Inkscape is not starting up with the correct
environment somehow. I don't know how to troubleshoot it beyond that.

I tried the original poster's suggestion of setting the display and
starting Inkscape from the command line, and it indeed works correctly
under those conditions. Because I already had the correct path set for
python 2.4 (and pyxml), I only needed to set the display export and start
inkscape with these commands:

export DISPLAY=0:0
/Applications/Inkscape.app/Contents/MacOS/Inkscape

And then everything works OK.

I hope this info helps; I'd be happy to go into more detail about this.

Revision history for this message
JiHO (jiho) wrote :

Originator: NO

Hello,

thanks for the additional info. So apparently Python versions from Python
Mac OS X installs in
/Library/Frameworks/Python.framework/Versions/Current/bin and this is not a
standard path (just as /sw/ and /opt/local are not standard). So the
problem is the same that with Fink and DarwinPort's pythons: Inkscape only
looks in standard PATH directories (/usr/bin:/usr/local/bin etc.). I can
add this additional directory to Inkscape PATH detection given how
important Python is for Inkscape but this will only affect new versions.
Your current solution is:
- to modify the PATH yourself: right click on Inkscape.app > Show packages
content, navigate to Contents/Ressources/bin, open the file "inkscape" with
a text editor and modify the PATH line accordingly (export
PATH="$CWD:$PATH" should become export
PATH=""$CWD:/Library/Frameworks/Python.framework/Versions/Current/bin:$PATH")
- to install a version of PyXML which works with your stock Mac OS X
python install. If you are on PPC, I already did the work for you, just
download it from there: http://inkscape.modevia.com/macosx-snap/?C=M;O=D or
with the PPC+python version of the most recent release of Inkscape (0.45).
If you are on Intel, it would be really nice if you could compile it and
then send me the binary so that I can make a package of it, similar to the
one for PPC. To compile it, follow the instructions there:
http://wiki.inkscape.org/wiki/index.php/CompilingMacOsX#Enabling_python_effects
but beware, in order to use you stock python install you need to remove the
extra python directories from your PATH (you can just comment it and
re-enable it afterwards). you'll need gcc from the development tools of
your Tiger DVD, do you have XCode installed?

Extra info: the .bash_* are kind of a mess on OS X (well, they are just a
"little" less messy on Linux). I personaly keep all my bash related info in
.bash_profile (Mac OS X usually put things in .profile AND in .bashrc and
possibly in .login, .bash_profile and .bash_login) and source this file in
.bashrc to keep everything similar for login (.bash_profile) and non login
(.bashrc) shells. So my .bashrc looks like:

# bash configuration file for non login shells
. ~/.bash_profile

Hope that helps.

Revision history for this message
Krolco (krolco) wrote :

Originator: NO

Great sleuth work! I will try out some of these suggestions.

FWIW, I am not the original poster of this issue, so hopefully this solves
that guy's problem also. :)

Please forgive my dumb: I don't normally do unix-style development, and I
don't really know anything about compiled python modules.

I did the compile as you asked (using the stock Python 2.3.5, which is the
default on OSX 10.4.9), but I don't know what to send you... so I tar'ed up
the whole thing.

You can grab it here:
http://www.krolco.net/PyXML-0.8.4-compiled-intel.tar.gz

Let me know if this is the right stuff... thanks!

Revision history for this message
JiHO (jiho) wrote :

Originator: NO

Actually you sent me the source folder. If you proceeded with the install
and everything, there should be a folder named _xmlplus in
/System/Library/Frameworks/Python.framework/Versions/Current/lib/python2.3/site-packages/.
Could you compress this folder and send it to me as you did with the other
one? (and if you install numpy similarly there will be a folder called
numpy in the same location and it would be great if you could send it to me
as well ;-))
Thanks a lot.

Revision history for this message
Krolco (krolco) wrote :

Originator: NO

I did send you the source folder, but it was after ran 'python setup.py
build'... I thought that would have the right stuff in it. :)

I did the install, and I build and installed numpy.

You can grab them in a single tgz:

http://www.krolco.net/xmlplus_numpy_intel.tar.gz

Please let me know if that had the right stuff for you!

Revision history for this message
JiHO (jiho) wrote :

Originator: NO

Perfect, thanks a bunch! I put those in a dmg and uploaded with the
development builds of Inkscape. I update Inkscape wiki also, mentionning
your nickname (krolco). Is it a problem?

Now, I would like to close this bug for user which have a newer Python
installed, different from the default one. Do you still have Python 2.4 or
do you work with the stock python now? If you still have the newer python,
it would be great if you test one of the solutions I mentioned below:

modify the PATH yourself: right click on Inkscape.app > Show packages
content, navigate to Contents/Ressources/bin, open the file "inkscape"
with
a text editor and modify the PATH line accordingly (export
PATH="$CWD:$PATH" should become export
PATH=""$CWD:/Library/Frameworks/Python.framework/Versions/Current/bin:$PATH")

It should be easy. Please tell me if this works with your Python 2.4 and
pyXML.dmg you downloaded before. If it works, we'll modify Inkscape
accordingly and close this bug.

Thanks a lot again.

Revision history for this message
Krolco (krolco) wrote :

Originator: NO

It's fine to mention my name. :) This is how open-source projects work,
right? :)

I will try out one of the other solutions as soon as I can (tonight,
California time).

I was thinking about the issue a bit more: the Python 2.4.4 distro I
installed from Pythonmac.org created links in /usr/local/bin to its
"nonstandard" path... so I guess I'm unclear why it didn't work in the
first place?

In any case, I'll try out one of the other solutions using Python 2.4.4.
as soon as I can.

Revision history for this message
JiHO (jiho) wrote :

Originator: NO

I think it did not work because /usr/local/bin is not in Mac OS X basic
PATH variable either (though it's kind of standard I agree, it's OS X
behavior here which is not standard). At least I remember having to add
/usr/local/bin manually to my PATH and I guess it was because it was not in
the PATH already. One more thing to add to Inkscape I guess ;-)

Revision history for this message
Krolco (krolco) wrote :

Originator: NO

Ah, good point... that makes sense. I had added /usr/local/bin to my
.bash_login and .bashrc, but I guess Inkscape doesn't honor those by
default. (Do any apps that are started by double-clicking? I don't really
know the environment rules)

Revision history for this message
Krolco (krolco) wrote :

Originator: NO

So I tested your solution for Python 2.4, and it seemed to work.

Here's what I did:

-- Removed the pyxml and numpy libs from my OS default (2.3.5) install --
so there would be no fallbacks. I verified that Inkscape failed to export
.DXF under these conditions (same error message as the original posting).

-- I modified the inkscape script in the app package just as you outlined
(changed the path export), and re-launched inkscape. I then verified that
the .DXF could be exported.

Seems to do the trick! Thanks a bunch. Let me know if you need anything
else.

Revision history for this message
JiHO (jiho) wrote :

Originator: NO

All sensible PATH additions should no be in inkscape launcher. Were
added:
/Library/Frameworks/Python.framework/Versions/Current/bin
/sw/bin
/opt/local/bin
/usr/local/bin
A better solution is probably to detect the user's
.bashrc/.profile/.bash_profile or whatever and use it. The issue is the
diversity of files in which PATH modifications can be made.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.