Comment 15 for bug 450927

adam (shrode) wrote :

I encountered this issue with Windows 8.1 64bit build 0.91pre4 r13712. In this case it was a pathing issue.

1. Install inkscape
2. PS C:\> if(![Environment]::GetEnvironmentVariable("PythonHome",[System.EnvironmentVariableTarget]::User)){[Environment]::SetEnvironmentVariable("PythonHome","c:\foobar",[System.EnvironmentVariableTarget]::User)}
3. Try to run a python extension

This issue occurs when the environment variable PythonHome exists and does not point to the python executable bundled with Inkscape; by default, "C:\Program Files\Inkscape\python"

Dependent on the situation, the message under "Technical details" changes:
  If PYTHONHOME points to another installed python environment, I get "DLL load failed: %1 is not a valid Win32 application."
  If PYTHONHOME points to a non-existent python environment, I get "No module named lxml"

For installs via package managers on *nix (Ubuntu), python and/or the associated pip extension "lxml" may be pulled in as a dependency and installed to the lib of the python version instantiated by it. So two different python environments exist, but are not sharing resources.

Windows: if no other Python version is installed you can delete the PythonHome variable:

PS C:\> if([Environment]::GetEnvironmentVariable("PythonHome",[System.EnvironmentVariableTarget]::User)){[Environment]::SetEnvironmentVariable("PythonHome","",[System.EnvironmentVariableTarget]::User)}
PS C:\> if([Environment]::GetEnvironmentVariable("PythonHome",[System.EnvironmentVariableTarget]::Machine)){[Environment]::SetEnvironmentVariable("PythonHome","",[System.EnvironmentVariableTarget]::Machine)}
and restart inkscape

or, consolidate the inkscape python lib (extensions) with the pre-existing python lib.

*nix: I cannot test for Ubuntu at the moment, but depending on your *nix, there are utilities to query the system for python; eselect (gentoo), python-config (neutral). To query the python executable that gets run; `ls -l $(which python)` will give you the path. You may also want to run `printenv | grep -i python`
You may also want to look at