0

I am teaching myself Python, and thanks to the great help I am getting here when I am stuck with something, I am happy with my progress.

I am working on a project that retrieves a bunch of records from several APIs, data mines addresses, extracts geolocations (using GeoPy), and now I want to visualize them in Google earth.

The perfect library for I want to do is PyKML. It looks pretty straightforward, specially since I want to recreate the "circle around locations" tour in the PyKML documentation, enabling me to do some programmatic creation of KML documents.

The problem I am having is that PyKML depends on lxml, and lxml depends on libxml2 & libxslt, and I have not been able to install any of them.

I am not sure what those libraries are for, and I don't even know if I can run then in my machine (I am using windows). The documentation for libxml2 and libxslt is particularly confusing to me, since there is mention of C language and compilers.

Could anybody indicate to me what's the proper way to "install" and test lxml, libxml2, and libxslt to use with Python? Does anybody know of other Python libraries that allow for programmatic creation of KML documents, and preferably, that do not depend on other libraries?

Thanks in advance for your help. Cheers


Solved

I solved the problem by uninstalling 64-bit version of Python for Windows and installing the 32-bit version.

Additionally, I installed the 32-bit binary build of lxml 2.3 for Python 2.6 from here:

http://pypi.python.org/pypi/lxml/2.3

I think the problem was incompatibility between some of the components of Python 2.6 64, and all the libraries the lxml needed to work.

CodeMonkey
  • 22,825
  • 4
  • 35
  • 75
Luis Miguel
  • 5,057
  • 8
  • 42
  • 75

2 Answers2

2

However, all these libraries should install with easy_install.

The PyKML documentation says

Given this, the first step to installing pyKML is to get lxml running on your system. Refer to the lxml website for instructions on how to install lxml.

If you are on a unix-like system (including OS X), libxml2 and libxslt are probably already installed, or can be installed easily through the native package manager.

For windows, lxml provides prebuilt eggs with libxml2 and libxslt staticly compiled in (as stated in the lxml install documentation), so you do not need to install them separately. From the lxml documentation:

Get the easy_install tool and run the following as super-user (or administrator):

easy_install --allow-hosts=lxml.de,*.python.org lxml

On MS Windows, the above will install the binary builds that we provide. If there is no binary build of the latest release yet, please search PyPI for the last release that has them and pass that version to easy_install.

It appears that the latest version is 2.3, so only if the above command does not work, try:

easy_install --allow-hosts=lxml.de,*.python.org lxml==2.3

From the error message you get when you easy_install PyKML, it sounds like easy_install is not finding your installed lxml package and is trying to install it for PyKML. You can try to force the issue with easy_install --no-deps pykml, which will ignore dependencies and just install PyKML (which is a simple python-only library). Then test if import pykml works, and if it does you are done.

Francis Avila
  • 31,233
  • 6
  • 58
  • 96
  • Francis, thank you for your reply. I am using Windows, I mentioned it in the original post. In any case, I still can't get lxml to work (I have not been able to install or test the other two libraries). – Luis Miguel Apr 18 '12 at 19:19
  • 1
    The lxml installation documentation for windows explicitly says that it provides a prebuilt binary via `easy_install` with libxml2 and libxslt compiled in, so you do *not* need to install them separately. Answer updated with explicit instructions for windows, but it's nothing that you could not have learned from the lxml installation documentation. – Francis Avila Apr 18 '12 at 20:41
  • Thank you. typing "Import lxml" from python seems to be OK, "lxml??" in ipython returns a brief description, etc. Now, when doing "easy_install pykml", it searches for the library, finds a match, downloads, starts building lxml version 2.3.4 and says "Building without Cython" ERROR: 'xslt-config' in not recognized as an internal or external command, operable program or batch file. **make sure the development packages of libxml2 and libxslt are installed. and then several warnings. Since I am using windows 7 64, I suspect a problem there. How can I post a JPG of the warnings here? – Luis Miguel Apr 18 '12 at 21:07
  • 1
    Post the text, not a jpg! Edit your original question. The problem here is that PyKML's installer wants to use the command-line utility `xslt-config`, which you don't have via lxml. Honestly I can't think of why PyKML would need that at all. – Francis Avila Apr 18 '12 at 21:11
0

I solved the problem by uninstalling 64-bit version of Python for Windows and installing the 32-bit version.

Additionally, I installed the 32-bit binary build of lxml 2.3 for Python 2.6 from here:

http://pypi.python.org/pypi/lxml/2.3

I think the problem was incompatibility between some of the components of Python 2.6 64, and all the libraries the lxml needed to work.

Luis Miguel
  • 5,057
  • 8
  • 42
  • 75