Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LXML installation for QGIS in Windows #8

Open
hkristen opened this issue Sep 23, 2016 · 1 comment
Open

LXML installation for QGIS in Windows #8

hkristen opened this issue Sep 23, 2016 · 1 comment

Comments

@hkristen
Copy link
Contributor

After playing around and searching in all kinds of internet forums I finally came up with a solution how to install lxml for the Qgis python version in WINDOWS. In Linux this is not an issue, as lxml is already included.

As the lxml module needs to be compiled before installing with pip, things are no so easy as normal when installing a python module. This text is based on:
http://quantumofgis.blogspot.it/2014/11/qgis-standalone-and-python-modules.html

My test system is following:
Windows 10, QGIS 2.16.2 mit Python 2.7.5, pip 8.1.2 und lxml 3.6.4

So first of all open your favorite Texteditor (my choice would be Notepad++) to create a file called 
pythonpath.bat and save it in the folder of your choice.

Using the latest official stable version of QGIS this file should contain the following text.

    SET PYTHONHOME=C:\Program Files\QGIS 2.16\apps\Python27
    SET PYTHONPATH=C:\Program Files\QGIS 2.16\apps\Python27\Lib
    SET PATH=%PYTHONHOME%;%PYTHONHOME%\Scripts;C:\Program Files\QGIS 2.16\bin;%PATH%

From the Windows "Start" Button search for cmd.exe, right click on it and choose  "Open as Administrator).

With the "normal" commands of using cd go to the folder where you saved the file from above (pythonpath.bat) and execute it from the commandline.

    > pythonpath.bat

You should now be able to start python from within this commandline by executing just

    > python

If you see something like Python 2.7.5 (default .......) and the command prompt switched to >>> you are in a python shell.
Leave it by pressing CTRL + Z followed by ENTER

Now we are going to install pip (an easy module management tool for python):

Download https://bootstrap.pypa.io/get-pip.py to your
Downloads folder and within the (still opened) Administrator cmd join that Download folder (again with using the cd command - if you are not already inside) with

    > cd C:\Users\username\Downloads

Then call that downloaded get-pip.py, but be careful you must not use the long names (Program Files, QGIS Brighton) but the short "DOS" names, otherwise the pip command will not work afterwards due to "wrong" stored paths inside its (created) binary.

To find the correct path in the short writings you can use the DOS command

    dir /x 

that will show the short name of the directory/file in its own column.
So the command to enter (depending on your Installation) is:

    C:\PROGRA~1\QGIS2~1.16\bin\python.exe get-pip.py

That will install pip and you can use pip to install the lxml module. 

As the normal installation of lxml with pip doesn´t work in Windows use the unofficial binary from Christoph Gohlke´s site [lxml-3.6.4-cp27-cp27m-win32.whl](http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml) 

    > pip install C:\xml-3.6.4-cp27-cp27m-win32.whl

Now the LXML module should be installed in your QGIS Python.  
@eox-cs1
Copy link
Member

eox-cs1 commented Sep 23, 2016

Thanks for providing these helpful instructions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants