简体   繁体   English

将LXML安装到virtualenv

[英]Install lxml into virtualenv

I am attempting to install the latest lxml module in a virtualenv with Python3.4 on Windows 7. As a long time Linux user, this process should be simple, but, of course, it's not. 我试图在Windows 7上使用Python3.4在virtualenv中安装最新的lxml模块。作为很长时间的Linux用户,这个过程应该很简单,当然,事实并非如此。 I'm trying to install the latest lxml, and there is currently no package that works with Python3.4+ Consequently, I acquired libxml2 and libxslt, but I cannot seem to get anything to recognize them. 我正在尝试安装最新的lxml,目前没有适用于Python3.4 +的软件包因​​此,我获得了libxml2和libxslt,但我似乎无法识别它们。 Can anyone point me in the right direction of linking everything together. 谁能指出我将所有事物链接在一起的正确方向。

I've tired pretty much everything from http://lxml.de/build.html and all the variants I can think of. 我已经厌倦了http://lxml.de/build.html以及我能想到的所有变种。 Any help would be much appreciated. 任何帮助将非常感激。

Error logs below: 错误日志如下:

Building lxml version 3.4.1.
Building with Cython 0.21.1.
ERROR: b"'xslt-config' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n"
** make sure the development packages of libxml2 and libxslt are installed **

Using build configuration of libxslt
missing cimport in module 'lxml.includes': src\lxml\lxml.etree.pyx
missing cimport in module 'lxml.includes.tree': src\lxml\lxml.etree.pyx
missing cimport in module 'lxml.python': src\lxml\lxml.etree.pyx
missing cimport in module 'lxml': src\lxml\lxml.etree.pyx
missing cimport in module 'lxml.includes': src\lxml\lxml.objectify.pyx
missing cimport in module 'lxml.includes.etreepublic': src\lxml\lxml.objectify.pyx
missing cimport in module 'lxml.includes.tree': src\lxml\lxml.objectify.pyx
missing cimport in module 'lxml': src\lxml\lxml.objectify.pyx
C:\Python34\Lib\distutils\dist.py:260: UserWarning: Unknown distribution option: 'bugtrack_url'
  warnings.warn(msg)
running build
running build_py
copying src\lxml\includes\lxml-version.h -> build\lib.win32-3.4\lxml\includes
running build_ext
building 'lxml.etree' extension
C:\minGW\bin\gcc.exe -mdll -O -Wall -IC:\Users\username\Desktop\angelScripts\draft\lxml-master\src\lxml\includes -IC:\Pyth
on34\include -IC:\Python34\include -c src\lxml\lxml.etree.c -o build\temp.win32-3.4\Release\src\lxml\lxml.etree.o -w
In file included from src\lxml\lxml.etree.c:239:0:
C:\Users\username\Desktop\angelScripts\draft\lxml-master\src\lxml\includes/etree_defs.h:14:31: fatal error: libxml/xmlvers
ion.h: No such file or directory
 #include "libxml/xmlversion.h"
                               ^
compilation terminated.
error: command 'C:\\minGW\\bin\\gcc.exe' failed with exit status 1

I downloaded lxml-3.4.4-cp34-none-win_amd64.whl from Christoph's Gohlke's Python page and install it using 我从Christoph's Gohlke的Python页面下载了lxml-3.4.4-cp34-none-win_amd64.whl ,并使用安装

pip install lxml-3.4.4-cp34-none-win_amd64.whl 

it worked for me. 它对我有用。

I'd recommend downloading lxml from Christoph Gohlke's Python Extension Packages for Windows Repository. 我建议从Christoph Gohlke的Windows扩展包中为Windows Repository下载lxml Select either lxml‑3.4.1.win‑amd64‑py3.4.exe or lxml‑3.4.1.win32‑py3.4.exe , depending on whether you're running a 64- or 32-bit Python installation, respectively. 选择lxml‑3.4.1.win‑amd64‑py3.4.exelxml‑3.4.1.win32‑py3.4.exe ,分别取决于运行的是64位还是32位Python安装。 Don't run the installer, but instead unzip it. 不要运行安装程序,而是将其解压缩。 Move the contents of the resulting PLATLIB folder (an lxml directory, and an lxml-3.4.1-py3.4.egg-info directory) to the site-packages folder in your virtualenv, and you should be all set. 将生成的PLATLIB文件夹(一个lxml目录和一个lxml-3.4.1-py3.4.egg-info目录)的内容移到virtualenv中的site-packages文件夹中,您应该已经lxml-3.4.1-py3.4.egg-info

I've just had this problem, and here's how I solved it: 我刚遇到这个问题,这是我解决的方法:

First try to pip install it. 首先尝试pip安装它。 Go to command prompt and type in C:/Python34/Scripts/pip install lxml 转到命令提示符并键入C:/ Python34 / Scripts / pip install lxml

If you still got an error, than go to Christoph's Gohlke's Python page 如果仍然有错误,请转到Christoph's Gohlke的Python页面

and then download the right lxml. 然后下载正确的lxml。 Generally since I use python 3.4 and I have a windows, I download the lxml-3.4.4-cp34-none-win32.whl 一般来说因为我使用python 3.4并且我有一个窗口,所以我下载了lxml-3.4.4-cp34-none-win32.whl

Now that you have a whl file, go to the folder it is in. Click in the background (so nothing is selected), then leftshift + rightclick at the same time and click on open command window. 现在你有一个whl文件,转到它所在的文件夹。在后台单击(所以没有选择任何内容),然后leftshift +同时右键单击并单击打开命令窗口。 Then type C:/Python34/Scripts/pip install "NAME OF THE FILE YOU JUST DOWNLOADED.whl" 然后输入C:/ Python34 / Scripts / pip install“你刚刚下载的文件的名称。”

and press enter. 然后按Enter键。 This worked well for me, and after you type the quote you can also press tab and it should fill the right one for you. 这对我来说效果很好,输入报价后你也可以按Tab键,它应该为你填写合适的报价。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM