将lxml安装到virtualenv中

时间:2014-12-08 17:41:19

标签: python windows virtualenv lxml

我正在尝试在Windows 7上使用Python3.4在virtualenv中安装最新的lxml模块。作为很长时间的Linux用户,这个过程应该很简单,当然,事实并非如此。我试图安装最新的lxml,目前没有适用于Python3.4 +的软件包因​​此,我获得了libxml2和libxslt,但我似乎无法识别它们。任何人都可以指出我将所有事物连接起来的正确方向。

我已经厌倦了http://lxml.de/build.html以及我能想到的所有变种。任何帮助将不胜感激。

以下错误日志:

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

3 个答案:

答案 0 :(得分:3)

我从Christoph's Gohlke's Python page下载了 lxml-3.4.4-cp34-none-win_amd64.whl 并使用

进行安装
@Override
    public View getView(int position, View convertView, ViewGroup parent) {

        if (inflater == null)
            inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.share_item, parent, false);
        }

        CheckBox checkBox = (CheckBox) convertView.findViewById(R.id.checkboxShare);

        TextView tvShareName = (TextView)convertView.findViewById(R.id.tvShareName);


        tvShareName.setText(shareList.get(position).getName());



        return convertView;
    }
它对我有用。

答案 1 :(得分:2)

我建议从Christoph Gohlke的Windows扩展程序包中下载lxml for Windows Repository。选择lxml‑3.4.1.win‑amd64‑py3.4.exelxml‑3.4.1.win32‑py3.4.exe,具体取决于您是否分别运行64位或32位Python安装。不要运行安装程序,而是将其解压缩。将生成的PLATLIB文件夹(lxml目录和lxml-3.4.1-py3.4.egg-info目录)的内容移动到virtualenv中的site-packages文件夹,您应该全部设置。< / p>

答案 2 :(得分:2)

我刚遇到这个问题,以及我如何解决这个问题:

首先尝试pip安装它。转到命令提示符并键入 C:/ Python34 / Scripts / pip install lxml

如果您仍然遇到错误,请转到Christoph's Gohlke's Python page

然后下载正确的lxml。一般来说因为我使用python 3.4并且我有一个窗口,所以我下载了lxml-3.4.4-cp34-none-win32.whl

现在你有一个whl文件,转到它所在的文件夹。在后台单击(所以没有选择任何内容),然后leftshift +同时右键单击并单击打开命令窗口。然后输入 C:/ Python34 / Scripts / pip install&#34;你刚刚下载的文件的名称。&#34;

然后按Enter键。这对我来说效果很好,输入报价后你也可以按Tab键,它应该为你填写正确的。