Pip如何能够通过名称或URL安装包?

2024-09-27 18:06:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我知道可以用pip按名称安装Python包,但最近我发现可以install Python packages by URL。例如:

pip install http://www.crummy.com/software/BeautifulSoup/unreleased/4.x/BeautifulSoup-4.0b.tar.gz

皮普是怎么做到的?如果包名看起来像一个URL怎么办?在


Tags: installpip名称comhttpurlbypackages
1条回答
网友
1楼 · 发布于 2024-09-27 18:06:41

如果有疑问,只需检查来源。Pip在他们的下载模块中有一个函数来检查输入的名称是否像URL。在

def is_url(name):
    """Returns true if the name looks like a URL"""
    if ':' not in name:
        return False
    scheme = name.split(':', 1)[0].lower()
    return scheme in ['http', 'https', 'file', 'ftp'] + vcs.all_schemes

你不能把模块的名字写在上面。在

如果你想把http:放在模块名称的开头,你可能没有编写我想下载的软件。在

相关问题 更多 >

    热门问题