python:如何在没有互联网连接的情况下创建 virtualenv [英] python: How to create virtualenv without internet connection

查看:40
本文介绍了python:如何在没有互联网连接的情况下创建 virtualenv的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在阻止所有互联网访问的服务器上创建 virtualenv 时遇到问题.以前有人成功过吗?我搜索但没有显示任何有用的东西.我来回传输数据没有问题,但我不知道需要下载哪些软件包以及安装需要哪些选项.

I have trouble creating a virtualenv on a server that blocks all internet access. Has anybody successfully done that before? I searched but doesn't show up anything helpful. I have no problem transferring data back and forth, but I don't know what packages need to be downloaded and what options I need to have for the installation.

如果你对我尝试创建一个的结果感到好奇,这里是回溯:

If you are curious what I got by trying to create one, here's the backtrace:

netops@netops1 /spare/local/latency $virtualenv -p /usr/bin/python2.6 latency
Running virtualenv with interpreter /usr/bin/python2.6
New python executable in latency/bin/python2.6
Also creating executable in latency/bin/python
Installing setuptools.....................
  Complete output from command /spare/local/latency/latency/bin/python2.6 -c "#!python
\"\"\"Bootstra...sys.argv[1:])






" --always-copy -U setuptools:
  Downloading http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg
Traceback (most recent call last):
  File "<string>", line 279, in <module>
  File "<string>", line 211, in main
  File "<string>", line 159, in download_setuptools
  File "/usr/lib64/python2.6/urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib64/python2.6/urllib2.py", line 391, in open
    response = self._open(req, data)
  File "/usr/lib64/python2.6/urllib2.py", line 409, in _open
    '_open', req)
  File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/usr/lib64/python2.6/urllib2.py", line 1181, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/usr/lib64/python2.6/urllib2.py", line 1156, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [Errno 110] Connection timed out>

感谢您的帮助.

推荐答案

如果您将 virtualenv 更新到版本 >= 1.10,那么无论任何标志如何,它都永远不会连接到 Internet(请参阅更改与新闻"部分这里)

If you update virtualenv to a version >= 1.10, then it will never connect to the internet regardless of any flag (see the "Changes & News" section here)

互联网连接用于在虚拟环境中安装 setuptoolspip 包.旧版本的 virtualenv 会尝试下载这两个包,而新版本会随它们一起提供,并在必要时将它们解压缩.

The internet connection is used to install the setuptools and pip packages in the virtual environment. Older versions of virtualenv will try to download these two packages, while newer versions ship with them and will just unpack them when necessary.

由于您的 virtualenv 版本 (1.7.2) 低于 1.10,您可以使用 --never-download 标志以避免连接到互联网.稍后,您可以安装(离线)您需要的东西.

Since your virtualenv version (1.7.2) is lower than 1.10, you can use the --never-download flag in order to avoid connecting to the internet. Later on, you can install (offline) what you need.

此处(--extra-search-dir 选项"部分") 解释了如何在没有互联网连接的情况下引导 setuptools 和 pip.你基本上需要获取这些包的 .egg 文件并将它们放在本地的某个地方,然后你需要做:

Here (section "The --extra-search-dir Option") it's explained how to bootstrap setuptools and pip without an internet connection. You basically need to get the .egg files for these packages and put them somewhere local, and then you need to do:

$ virtualenv --extra-search-dir=/path/to/eggs --never-download ENV

这篇关于python:如何在没有互联网连接的情况下创建 virtualenv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆