0

我正在尝试使用 virtualenv 进行测试。不幸的是,我碰到了一堵墙,

当我尝试从内部 pypi 服务器 pip 安装我的应用程序时,它失败了。我认为这是因为 virtualenv 使用的是自己的 pip 而不是全局的。

我怎样才能让它使用全局点子?

这就是我正在做的事情:

virtualenv ENV
source ENV/bin/activate
pip install django  <---- this works
pip install django-tyrell  <---- this cant be found

这是输出

[localhost] run: pip install django-tyrell
[localhost] out: Downloading/unpacking django-tyrell
[localhost] out:   Could not find any downloads that satisfy the requirement django-tyrell
[localhost] out: No distributions at all found for django-tyrell
[localhost] out: Storing complete log in /tmp/tmpGLJUzf
[localhost] out: 


Fatal error: run() received nonzero return code 1 while executing!

Requested: pip install django-tyrell
Executed: /bin/bash -l -c "cd fabrics && source ENV/bin/activate && pip install django-tyrell"
4

1 回答 1

0

想到的一种解决方案是使用完整路径运行 pip ,例如:

> /usr/bin/pip install django-tyrell

示例假设您的全局pip位于/usr/bin.

要在评论中添加您的第二个问题 - 不,您不能避免pip安装virtualenv

def create_environment(home_dir, site_packages=False, clear=False,
                       unzip_setuptools=False, use_distribute=False,
                       prompt=None, search_dirs=None, never_download=False):
    """
    Creates a new environment in ``home_dir``.

    If ``site_packages`` is true, then the global ``site-packages/``
    directory will be on the path.

    If ``clear`` is true (default False) then the environment will
    first be cleared.
    """
    home_dir, lib_dir, inc_dir, bin_dir = path_locations(home_dir)

    py_executable = os.path.abspath(install_python(
        home_dir, lib_dir, inc_dir, bin_dir,
        site_packages=site_packages, clear=clear))

    install_distutils(home_dir)

    if use_distribute:
        install_distribute(py_executable, unzip=unzip_setuptools,
                           search_dirs=search_dirs, never_download=never_download)
    else:
        install_setuptools(py_executable, unzip=unzip_setuptools,
                           search_dirs=search_dirs, never_download=never_download)

    install_pip(py_executable, search_dirs=search_dirs, never_download=never_download)

    install_activate(home_dir, bin_dir, prompt)

从你所看到的,install_pip()被称为不管。

于 2013-01-29T02:12:59.780 回答