您的位置:

pip报错InstallationError("The URL {!r} has an empty revision (after @) ""which is not supported. Include a revision after @ ""or remove @ from the URL.".format(url))怎么办

  发布时间:2025-03-10 11:21:52
整理了 pip 出现空版本号错误的问题原因和解决方案,包括在URL后添加版本号、修改requirements.txt文件、在Git仓库URL中包含正确分支或标签信息等方法,以及具体例子说明如何指定版本号或移除@符号来解决错误。

问题原因

pip 出现 InstallationError("The URL {!r} has an empty revision (after @) which is not supported. Include a revision after @ or remove @ from the URL.".format(url)) 错误的原因可能是由于在安装依赖包时,URL 指定的版本号在 @ 符号后面为空,但 pip 不支持空的版本号。这个错误一般发生在依赖包链接中指定了空的版本号时。PIP 要求在 URL 的 @ 符号后面指定一个有效的版本号,以便正确地确定要安装的软件包的版本。

解决方案

出现 InstallationError("The URL {!r} has an empty revision (after @) which is not supported. Include a revision after @ or remove @ from the URL.".format(url)) 这个错误通常是由于在 pip 安装时指定的 URL 中缺少版本信息导致的。要解决这个问题,需要根据具体情况采取以下解决方案: 1. 如果你是通过 pip 安装的一个包,可以尝试去官方网站或仓库找到正确的 URL 地址,并将版本信息添加到 URL 后面。在 URL 的末尾使用 @ 符号指定正确的版本号,例如 package_name@version。 2. 如果在 requirements.txt 文件中,将正确的包名和版本号写明,然后再通过 pip install -r requirements.txt 安装依赖包。 3. 如果是通过 Git 仓库安装的,确保在 git+ 后面的 URL 中包含正确的分支或标签信息,例如 git+https://github.com/user/repo.git@branch_or_tag。 4. 可以尝试移除 URL 中的 @ 符号,如果包含 @ 符号的话,因为有些情况下可能不需要指定版本号。 5. 确保 URL 地址是正确的,没有拼写错误或者其他语法错误。 请根据具体情况选择以上解决方案之一来解决 InstallationError("The URL {!r} has an empty revision (after @) which is not supported. Include a revision after @ or remove @ from the URL.".format(url)) 这个错误。

具体例子

当出现 InstallationError("The URL {!r} has an empty revision (after @) which is not supported. Include a revision after @ or remove @ from the URL.".format(url)) 错误时,这通常意味着在使用pip安装包时未指定正确的版本号。解决这个问题的方法是要么在URL中指定包的版本号,要么在URL中移除@符号。 具体来说,正确使用方法如下: 1. 指定包的版本号:


pip install package_name==version_number

这样就明确指定了要安装的包的版本号。 2. 移除@符号:


pip install package_name

如果你之前在URL中包含了@符号,可以尝试移除@符号,让pip自动选择合适的版本进行安装。 举例说明: 假设出现了 InstallationError("The URL {!r} has an empty revision (after @) which is not supported. Include a revision after @ or remove @ from the URL.".format(url)) 错误,我们要安装的包是 requests,可以这样处理: 1. 指定版本号安装:


pip install requests==2.25.1

在这个例子中,我们明确指定了安装 requests 包的 2.25.1 版本。


pip install requests

这样pip将会自动选择适当的版本安装 requests 包。 通过以上两种方法,你可以避免 InstallationError 中提示的空版本号错误,并成功安装需要的包。