Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

libxml not recognized in windows 10 inkscape 0.92

Tags:

inkscape

Inkscape complained about no libxml, so I installed lxml for windows 10. It complained again during modify path -> jitter nodes. so I restarted Inkscape. It is still complaining. Any know know how to fix this? Thanks in advance

error: The fantastic lxml wrapper for libxml2 is required by inkex.py and therefore this extension.Please download and install the latest version from http://cheeseshop.python.org/pypi/lxml/, or install it through your package manager by a command like: sudo apt-get install python-lxml

Technical details: DLL load failed: %1 is not a valid Win32 application.

like image 816
Swtsvn Avatar asked Dec 24 '22 21:12

Swtsvn


1 Answers

I've just faced "this" bug in Windows 7 64b and InkScape 0.92.2 and I'd like to give a little talkative answer, to shed some light on the background of this "fantastic" phenomenon. Note that the "Technical details" of the error message seem to be different with different people = they are likely a host of various underlying problems, resulting from different misconfigurations surfacing in different people's Windows system images, or possibly different glitches occuring in the Inkscape installer package for Windows (various historical versions).

First of all: note that some "peripheral" stuff in Inkscape is implemented as Python scripts or modules - such as, file imports and exports (some formats at least, mine was the DXF) and maybe the built-in help. This means that a Python runtime engine is needed for those functions of Inkscape to work.

Python is a popular interpreted language and it can so happen that you have a pre-existing system-wide install of Python (some version) on your PC, at the time you install Inkscape.

Regardless of whether you have some Python on your PC already or not, the Inkscape installer offers to install Python along with Inkscape (an option in the installer). The EXE installer definitely does contain a check mark in that vein, not sure about the MSI installer variant (I seem to recall that the set of selectable options is not as rich in the MSI installer variant).

And here comes the catch: this Python runtime, as installed by Inkscape, is not installed system-wide. Instead, it lives in C:\Program Files\Inkscape. There's even a python.exe.

For comparison: the standard system-wide Python lives in C:\Python27\ by default.

To solve the "fantastic" syndrome, some recommend to set the PYTHONPATH environment variable (system-wide if need be) to point to the Inkscape's own Python library folder. In my case, this didn't make a difference to Inkscape, the problem with missing lxml was still there all the same. At the same time, it disrupted my system-wide python instance - guess why :-)

I quickly realized that in my case, the "Inkscape's own" Python was possibly missing the lxml library. So I set the PYTHONPATH, launched a CMD with admin privileges, CD'ed into \Program Files\Inkscape, downloaded a copy of get-pip.py and ran that within the Inkscape Python environment. That did not succeed to install pip (which IMO is a requirement before "pip install lxml"). I don't recall the precise error message, but it just didn't work out.

Next, I figured out that the other way out would be to avoid installing Python within the Inkscape installer, and rely on a system-wide Python. I used to have some pre-existing Python 2.7.x, but managed to uninstall that while I was hunting the "fantastic syndrome". So I uninstalled Inkscape as well, removed my own definition of PYTHONPATH, and did a clean install of both Python and Inkscape. I first downloaded Python 2.7.13 from the upstream/official download site, cliked that I wanted PIP installed along with Python, once Python was all comfy in C:\Python27, I ran "pip install lxml" (and a couple other libs, such as the NumPy that I need for the RTL-SDR Scanner). After that, I installed Inkscape using the EXE installer and I made sure that the Inkscape's own Python was NOT checked for installation in the Inkscape installer.

Lo and behold, problem gone. Inkscape calls the system-wide Python interpreter to run its file export scripts. Everybody's happy.

Apart from PYTHONPATH, watch out for a custom path in the PYTHONHOME environment variable (might be left over from your past experiments with Python).

There's a way to test if lxml is installed:

C:> python
>>> import lxml
>>> lxml
<module 'lxml' from 'C:\Python27\lib\site-packages\lxml\__init__.pyc'>
>>> quit()

See also this topic for a display of the lxml version installed.

like image 59
frr Avatar answered Dec 26 '22 09:12

frr