Installing lxml on windows

Installing lxml

For special installation instructions regarding MS Windows and MacOS-X, see the specific sections below.

Requirements

You need Python 2.4 or later.

Unless you are using a static binary distribution (e.g. from a Windows binary installer), you need to install libxml2 and libxslt, in particular:

  • libxml2 2.6.21 or later. It can be found here: http://xmlsoft.org/downloads.html
    • We recommend libxml2 2.7.8 or a later version.
    • If you want to use XPath, do not use libxml2 2.6.27.
    • If you want to use the feed parser interface, especially when parsing from unicode strings, do not use libxml2 2.7.4 through 2.7.6.
  • libxslt 1.1.15 or later. It can be found here: http://xmlsoft.org/XSLT/downloads.html
    • We recommend libxslt 1.1.26 or later.

Newer versions generally contain fewer bugs and are therefore recommended. XML Schema support is also still worked on in libxml2, so newer versions will give you better compliance with the W3C spec.

Installation

Unless you are on MS Windows, the best way to install lxml is to get the pip package management tool and run the following as super-user (or administrator):

To install a specific version, either download the distribution manually and let pip install that, or pass the desired version to pip:

For MS Windows, we no longer provide binary distributions. Also see the related FAQ entry. If you fail to build lxml on your MS Windows system from the signed and tested sources that we release, consider using the unofficial Windows binaries that Christoph Gohlke generously provides.

On Linux (and most other well-behaved operating systems), pip will manage to build the source distribution as long as libxml2 and libxslt are properly installed, including development packages, i.e. header files, etc. Use your package management tool to look for packages like libxml2-dev or libxslt-devel if the build fails, and make sure they are installed. Alternatively, setting STATIC_DEPS=true will download and build both libraries automatically.

On MacOS-X, use the following to build the source distribution, and make sure you have a working Internet connection, as this will download libxml2 and libxslt in order to build them:

Building lxml from sources

If you want to build lxml from the GitHub repository, you should read how to build lxml from source (or the file doc/build.txt in the source tree). Building from developer sources or from modified distribution sources requires Cython to translate the lxml sources into C code. The source distribution ships with pre-generated C source files, so you do not need Cython installed to build from release sources.

If you have read these instructions and still cannot manage to install lxml, you can check the archives of the mailing list to see if your problem is known or otherwise send a mail to the list.

Using lxml with python-libxml2

If you want to use lxml together with the official libxml2 Python bindings (maybe because one of your dependencies uses it), you must build lxml statically. Otherwise, the two packages will interfere in places where the libxml2 library requires global configuration, which can have any kind of effect from disappearing functionality to crashes in either of the two.

To get a static build, either pass the —static-deps option to the setup.py script, or run pip with the STATIC_DEPS or STATICBUILD environment variable set to true, i.e.

Читайте также:  Как удалить проблему с подлинностью windows

The STATICBUILD environment variable is handled equivalently to the STATIC_DEPS variable, but is used by some other extension packages, too.

MS Windows

Most MS Windows systems lack the necessarily tools to build software, starting with a C compiler already. Microsoft leaves it to users to install and configure them, which is usually not trivial and means that distributors cannot rely on these dependencies being available on a given system. In a way, you get what you’ve paid for and make others pay for it.

Due to the additional lack of package management of this platform, it is best to link the library dependencies statically if you decide to build from sources. For that, use the binary distribution of libxml2 and libxslt. You need both libxml2 and libxslt, as well as iconv and zlib, which you can get from the same download site. Further build instructions are in the source build documentation.

MacOS-X

A macport of lxml is available. Try something like port install py25-lxml .

If you want to use a more recent lxml release, you may have to build it yourself. Apple doesn’t help here, as MacOS-X is so badly maintained by them that the pre-installed system libraries of libxml2 and libxslt tend to be horribly outdated, and updating them is everything but easy. In any case, you cannot run lxml with the system provided libraries, so you have to use newer libraries.

Installing lxml

lxml is generally distributed through PyPI.

Most Linux platforms come with some version of lxml readily packaged, usually named python-lxml for the Python 2.x version and python3-lxml for Python 3.x. If you can use that version, the quickest way to install lxml is to use the system package manager, e.g. apt-get on Debian/Ubuntu:

For MacOS-X, a macport of lxml is available. Try something like

To install a newer version or to install lxml on other systems, see below.

Requirements

You need Python 2.7 or 3.4+.

Unless you are using a static binary distribution (e.g. from a Windows binary installer), lxml requires libxml2 and libxslt to be installed, in particular:

  • libxml2 version 2.9.2 or later.
  • libxslt version 1.1.27 or later.
    • We recommend libxslt 1.1.28 or later.

Newer versions generally contain fewer bugs and are therefore recommended. XML Schema support is also still worked on in libxml2, so newer versions will give you better compliance with the W3C spec.

To install the required development packages of these dependencies on Linux systems, use your distribution specific installation tool, e.g. apt-get on Debian/Ubuntu:

For Debian based systems, it should be enough to install the known build dependencies of the provided lxml package, e.g.

Installation

If your system does not provide binary packages or you want to install a newer version, the best way is to get the pip package management tool (or use a virtualenv) and run the following:

If you are not using pip in a virtualenv and want to install lxml globally instead, you have to run the above command as admin, e.g. on Linux:

To install a specific version, either download the distribution manually and let pip install that, or pass the desired version to pip:

To speed up the build in test environments, e.g. on a continuous integration server, disable the C compiler optimisations by setting the CFLAGS environment variable:

(The option reads «minus Oh Zero», i.e. zero optimisations.)

Читайте также:  Scheduling task in linux

MS Windows

For MS Windows, recent lxml releases feature community donated binary distributions, although you might still want to take a look at the related FAQ entry. If you fail to build lxml on your MS Windows system from the signed and tested sources that we release, consider using the binary builds from PyPI or the unofficial Windows binaries that Christoph Gohlke generously provides.

Linux

On Linux (and most other well-behaved operating systems), pip will manage to build the source distribution as long as libxml2 and libxslt are properly installed, including development packages, i.e. header files, etc. See the requirements section above and use your system package management tool to look for packages like libxml2-dev or libxslt-devel . If the build fails, make sure they are installed.

Alternatively, setting STATIC_DEPS=true will download and build both libraries automatically in their latest version, e.g. STATIC_DEPS=true pip install lxml.

MacOS-X

On MacOS-X, use the following to build the source distribution, and make sure you have a working Internet connection, as this will download libxml2 and libxslt in order to build them:

Building lxml from dev sources

If you want to build lxml from the GitHub repository, you should read how to build lxml from source (or the file doc/build.txt in the source tree). Building from developer sources or from modified distribution sources requires Cython to translate the lxml sources into C code. The source distribution ships with pre-generated C source files, so you do not need Cython installed to build from release sources.

If you have read these instructions and still cannot manage to install lxml, you can check the archives of the mailing list to see if your problem is known or otherwise send a mail to the list.

Using lxml with python-libxml2

If you want to use lxml together with the official libxml2 Python bindings (maybe because one of your dependencies uses it), you must build lxml statically. Otherwise, the two packages will interfere in places where the libxml2 library requires global configuration, which can have any kind of effect from disappearing functionality to crashes in either of the two.

To get a static build, either pass the —static-deps option to the setup.py script, or run pip with the STATIC_DEPS or STATICBUILD environment variable set to true, i.e.

The STATICBUILD environment variable is handled equivalently to the STATIC_DEPS variable, but is used by some other extension packages, too.

Source builds on MS Windows

Most MS Windows systems lack the necessarily tools to build software, starting with a C compiler already. Microsoft leaves it to users to install and configure them, which is usually not trivial and means that distributors cannot rely on these dependencies being available on a given system. In a way, you get what you’ve paid for and make others pay for it.

Due to the additional lack of package management of this platform, it is best to link the library dependencies statically if you decide to build from sources, rather than using a binary installer. For that, lxml can use the binary distribution of libxml2 and libxslt, which it downloads automatically during the static build. It needs both libxml2 and libxslt, as well as iconv and zlib, which are available from the same download site. Further build instructions are in the source build documentation.

Source builds on MacOS-X

If you are not using macports or want to use a more recent lxml release, you have to build it yourself. While the pre-installed system libraries of libxml2 and libxslt are less outdated in recent MacOS-X versions than they used to be, so lxml should work with them out of the box, it is still recommended to use a static build with the most recent library versions.

Читайте также:  Windows 10 настройка видеопамяти

Как установить модуль lxml?

Не могу установить модуль lxml
Доброго времени суток! Не могу установить модуль lxml через pip.exe в Python 3.5 Сначала.

Как установить lxml?
При компиляции вылазит ошибка как исправить? Что я использую lxml 3.3.5 python 3.4.1 MinGW.

Как установить lxml?
Для модуля LXML требует libxml2 и libxslt. Поискал информации в интернете, и как я понял, для.

Не могу установить lxml
Всем доброго времени суток, перейду сразу к делу, нужно установить либу lxml, для этого в консоли.

yanita, тогда только страдать.

Добавлено через 4 минуты
Хотя для Python есть еще пакетный менеджер, easy_install, но мне его, вроде бы, использовать не приходилось, так что ничего по нему конкретного сказать не могу. Хотя некоторые мнения легко гуглятся: http://stackoverflow.com/quest. sy-install

(он поставится большей частью в /usr/lib/python3.3/site-packages и создаст простенький скрипт вызова /usr/bin/pip — это на случай, когда удалить захочешь)
Остальные python-пакеты можно ставить через pip.
Если не ставится — выкладывай лог ошибок.

Добавлено через 7 минут
/usr/lib не доступна на запись под юзером, поэтому запускать из под root:

Заказываю контрольные, курсовые, дипломные и любые другие студенческие работы здесь или здесь.

Установить библиотеку lxml по инструкции
Всем привет. Знаю что на форуме уже есть гайд на тему «как установить библиотеку», но увы этот гайд.

Как установить модуль requests?
Открываю setup в python — ошибка какая-то Добавлено через 39 секунд no such file or directory.

Как установить модуль rdtsc?
Здравствуйте! Решил найти пример использования модуля Threading. Нашёл пример. Собственно, вот.

Как установить модуль requests?
я не знаю что такое PIP, поэтому нажал на downlod tarball, скачал, то что было в архиве скинул в.

How to install lxml on Windows 8 64-bit with Python 3.4

C:\Users\Hima\Documents\Installers\python\packages>python -m pip install lxml-3.4.4-cp34-none-win_amd64.whl
lxml-3.4.4-cp34-none-win_amd64.whl is not a supported wheel on this platform.

Windows x86 (64-bit)
Installed Visual Studio C++ 2014
Python 3.4
I use pip (or pip3.4.exe; built-in to Python 3.4) to pip install lxml

gohlke/pythonlibs/#lxml shows as not supported.
2. In the following Package Index for lxml, there isn’t a suitable lxml file for 64 bit and Python 3.4. https://pypi.python.org/pypi/lxml/3.4.4

2 Answers 2

I have been struggling with this today. I found, elsewhere on stackoverflow.com, this two-part and quick solution, which resulted in python no longer complaining when I tried to use lxml:

  1. Go to this repository and download a version which matches your Python installation (the version number, and 32- vs 64-bit. I use Python 3.5.1 64-bit, installed on Windows 10, so on that page, I chose lxml-3.6.0-cp35-cp35m-win_amd64.whl.

You say you use Python 3.4, so use a version that matches that (or maybe the one you already have).

There is some helpful information at the top of the page about which version of CPython the files are built against.

The output of python -v will also tell you which version of MSVC++ was used to build your version of the python executable.

This answer is useful for determining MSVC versions from the output of python -v (which contains a build number instead of a version number).

My download directory is d:\Downloads. Python must be in your PATH environment variable for the next step to work. Use a command like the following, changing «D:\Downloads» to the pathname to your download directory. Then, at a DOS prompt, type:

  1. python -m pip install «D:\Downloads\lxml-3.6.0-cp35-cp35m-win_amd64.whl» lxml-3.6.0-cp35-cp35m-win_amd64.whl
Оцените статью