在我的开发环境中,由于一些网络问题,当我运行时:
(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 key复制过来。无论如何我可以告诉 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`.
最佳答案
可以的,命令是:
pip install --no-index --find-links=file:///[absolute path to your tar.gz]
关于python - 可以通过本地包 tar.gz 文件 pip 安装 python egg,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16241990/