简体   繁体   English

在virtualenv中为windows安装lxml

[英]Installing lxml in virtualenv for windows

I've recently started using virtualenv, and would like to install lxml in this isolated environment. 我最近开始使用virtualenv,并希望在这个孤立的环境中安装lxml。

Normally I would use the windows binary installer, but I want to use lxml in this virtualenv (not globally). 通常我会使用windows二进制安装程序,但我想在这个virtualenv中使用lxml(不是全局的)。 Pip install does not work for lxml, so I'm at a loss for what I can do. Pip安装对lxml不起作用,所以我无法做我能做的事情。

I've read that creating symlinks may work, although I unfamiliar with how symlinks work and what files I should be creating them for. 我已经读过创建符号链接可能会起作用,虽然我不熟悉符号链接的工作方式以及我应该创建它们的文件。 Does anyone else know of any methods to install lxml in a virtualenv on Windows? 有没有其他人知道在Windows上的virtualenv中安装lxml的任何方法?

If creating symlinks is the only method that works I'm definitely willing to learn if someone can point me in the right direction. 如果创建符号链接是唯一有效的方法我肯定愿意学习是否有人可以指出我正确的方向。

  1. Download lxml: http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml 下载lxml: http ://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml
  2. Activate virtualenv 激活virtualenv
  3. easy_install /path/to/the/file/lxml-3.2.1.win32-py3.3.‌exe

The easiest way is to simply copy the library into your virtualenv site-packages folder. 最简单的方法是将库复制到virtualenv site-packages文件夹中。 Symlinking is method of making it appear on the filesystem that the file is there but physically in another location. 符号链接是一种使文件出现在文件系统上的方法,即文件在那里但在物理上位于另一个位置。 It would be truly isolated if you copied the library over. 如果你复制了库,它将是真正的孤立。

So go into your global site-packages folder and copy over both the lxml folder and lxml egg folder into your virtualenv site-packages. 因此,进入您的全局站点包文件夹,并将lxml文件夹和lxml egg文件夹复制到您的virtualenv站点包中。 If you really wanted to symlink (for NTFS), look here . 如果你真的想要符号链接(对于NTFS),请看这里

Just wanted to add that emeraldo.cs's answer is correct, but you also have to copy the lxml related files that exist in the site-packages root. 只想添加emeraldo.cs的答案是正确的,但您还必须复制site-packages root中存在的lxml相关文件。 Once all the files are copied, pip will think it's installed. 复制完所有文件后,pip会认为它已经安装完毕。

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

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