Installing lxml, libxml2, libxslt for Python 3.5 on Windows 10

前端 未结 2 917
情歌与酒
情歌与酒 2021-01-15 02:23

I first try to run the basic pip install command for it:

C:\\Program Files (x86)\\Python35-32>pip install lxml
Collecting lxml
  Using cached lxml-3.6.4.t         


        
相关标签:
2条回答
  • 2021-01-15 02:47

    Also, check your pip --version. I had v19.0 and Gohlke .whl binaries would not install. Upgrade to 19.2 or greater.

    0 讨论(0)
  • 2021-01-15 02:58

    lxml uses libxml2, libxslt (in background) but libxml2, libxslt are not Python modules - it's C/C++ libraries. So you can't install them using pip. You have to download and install them manually.

    You can find precompiled lxml for Windows on Unofficial Windows Binaries for Python Extension Packages

    • cp35 in file name means version for Python 3.5.
    • win32 in file name means version for 32bit Python.
    • amd64 in file name means version for 64bit Python.

    You probably use 32bit Python because I see 32 and (x86) in your path

    C:\program files (x86)\python35-32\python.exe
    

    You should find links to libxml2, libxslt on this page too. This libraries has .dll and .exe files and you can put them in any folder which is in PATH variable. Libraries mostly are installed in C:\Windows or in subfolder.

    libxml2, libxslt may have also C/C++ header files *.h which you may need when you compile lxml. (on Linux this files are in separated packages libxml2-dev, libxslt-dev)


    BTW: You can use Anaconda distribution (instead of Python.org distribution). It installs the same Python but with some precompiled modules - ie. it installs lxml automatically. Anaconda can be the best solution for Windows users.

    List of all modules: https://docs.continuum.io/anaconda/pkg-docs

    0 讨论(0)
提交回复
热议问题