在我的开发环境中,由于一些网络问题,当我运行时:
(my-virt-env)$ pip install lxml
它始终因以下原因而失败:
Downloading/unpacking lxml
Downloading lxml-3.1.2.tar.gz (3.3Mb): 1.2Mb downloaded
Exception:
Traceback (most recent call last):
blablabla
error: [Errno 104] Connection reset by peer
然后我从其他地方下载了lxml-3.1.2.tar.gz,并使用usb密钥将其复制过来。无论如何我可以告诉pip没有费心去上网这个包,只需通过本地tar.gz安装它?所以我可以这样做:
(my-virt-env)$ pip install ${local_path}/lxml*.tar.gz
试过这个命令,我得到很长的错误信息:
pip install /home/shengjie/Downloads/lxml-3.1.2.tar.gz
Unpacking /home/shengjie/Downloads/lxml-3.1.2.tar.gz
Running setup.py egg_info for package from file:///home/shengjie/Downloads/lxml-3.1.2.tar.gz
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
warnings.warn(msg)
Building lxml version 3.1.2.
Building without Cython.
ERROR: /bin/sh: 1: xslt-config: not found
** make sure the development packages of libxml2 and libxslt are installed **
......................
bla bla bla
......................
/tmp/pip-Vg13dM-build/src/lxml/includes/etree_defs.h:9:31: fatal error: libxml/xmlversion.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
I am running Ubuntu, I know you can run `apt-get install python-lxml` and get it installed on your box. But that doesn't work for my case as I want install it in my virtual env: `my-virt-env`.
答案 0 :(得分:6)
你可以这样做,命令是:
pip install --no-index --find-links=file:///[absolute path to your tar.gz]
答案 1 :(得分:2)
我所看到的是,它抱怨缺少libxml2和libxslt的DEV版本。
对这两个软件包libxml2-dev和libxslt-dev进行apt-get安装,然后再次执行pip安装,看看情况如何。