使用PIP安装包装时跳过错误

Pro*_*eus 9 python

我跑了一下

pip install -r /requirements.txt
Run Code Online (Sandbox Code Playgroud)

如果我的一个软件包出现故障,整个过程就会中止,并且不会安装任何其他软件包.

是否有一个命令,如果发生错误,它将继续安装下一个包?

所以对于我的用例:这是我使用fab文件做的事情:

def _install_requirements():
    """
    Installs the required packages from the requirements.txt file using pip.
    """

    if not exists(config.SERVER_PROJECT_PATH + '/requirements.txt', use_sudo=True):
        print('Could not find requirements')
        return
    sudo('pip install -r %s/requirements.txt' % SERVER_PROJECT_PATH)
Run Code Online (Sandbox Code Playgroud)

phi*_*hem 4

有一个方便的 python 脚本,用于使用 pip 更新所有库(源代码):

import pip
from subprocess import call

for dist in pip.get_installed_distributions():
    call("pip install --upgrade " + dist.project_name, shell=True)
Run Code Online (Sandbox Code Playgroud)

在“for”循环中,您可以循环遍历需求。

# read requirements.txt file, create list of package names
for package in requirements:
    call("pip install " + package, shell=True)
Run Code Online (Sandbox Code Playgroud)

如果您无法安装软件包,这不会崩溃。