python – pip尝试在未安装git时使用git

python – pip尝试在未安装git时使用git,第1张

概述我有一个项目文件夹,它是一个git存储库(有一个.git文件夹).当我使用命令pip freeze时,pip尝试使用git.但是,我的系统上没有安装git,因此会导致错误: (env) PS C:\Users\eclaird\work\myproject> pip freezeCannot find command 'git'Storing complete log in C:\Users\e 我有一个项目文件夹,它是一个git存储库(有一个.git文件夹).当我使用命令pip freeze时,pip尝试使用git.但是,我的系统上没有安装git,因此会导致错误:

(env) PS C:\Users\eclaird\work\myproject> pip freezeCannot find command 'git'Storing complete log in C:\Users\eclaird\pip\pip.log(env) PS C:\Users\eclaird\work\myproject>

pip.log:

------------------------------------------------------------C:\Users\eclaird\work\env\Scripts\pip-script.py run on 01/09/14 11:54:42Cannot find command 'git'Exception information:Traceback (most recent call last):  file "C:\Users\eclaird\work\env\lib\site-packages\pip\basecommand.py",line 134,in main    status = self.run(options,args)  file "C:\Users\eclaird\work\env\lib\site-packages\pip\commands\freeze.py",line 73,in run    req = pip.FroZenRequirement.from_dist(dist,dependency_links,find_Tags=find_Tags)  file "C:\Users\eclaird\work\env\lib\site-packages\pip\__init__.py",line 180,in from_dist    req = get_src_requirement(dist,location,find_Tags)  file "C:\Users\eclaird\work\env\lib\site-packages\pip\vcs\__init__.py",line 249,in get_src_requirement    return version_control().get_src_requirement(dist,find_Tags)  file "C:\Users\eclaird\work\env\lib\site-packages\pip\vcs\git.py",line 151,in get_src_requirement    repo = self.get_url(location)  file "C:\Users\eclaird\work\env\lib\site-packages\pip\vcs\git.py",line 122,in get_url    [self.cmd,'config','remote.origin.url'],file "C:\Users\eclaird\work\env\lib\site-packages\pip\vcs\__init__.py",line 110,in cmd    command = find_command(self.name)  file "C:\Users\eclaird\work\env\lib\site-packages\pip\util.py",line 108,in find_command    raise BadCommand('Cannot find command %r' % cmd)BadCommand: Cannot find command 'git'

有没有办法在pip中禁用git集成?

(pip 1.4.1,
Python 2.7.6)

解决方法 很不幸的是,不行.没有配置选项来启用/禁用后端.

通过挖掘代码找到的详细信息:

Git模块始终注册:在pip/install.py中,导入git module.在它结束时,它会自己注册,因此只要在’git.Git’中声明的一个方案与依赖的url匹配,就会被查询.

schemes = ('git','git+http','git+https','git+ssh','git+git','git+file')

没有处理异常Funnily,冻结预计在确定要冻结的依赖URL时可能会发生错误.摘自pip.FrozenRequirement:

try:    req = get_src_requirement(dist,find_Tags)except InstallationError:    logger.warn("Error when trying to get requirement for VCS system %s,falling back to uneditable format" % ex)

InstallationError inherits from PipError.不幸的是,引发了类型”BadCommand’的例外,它继承自’aptError’.

所以,除了黑客攻击:你无能为力.如果你需要这个,你需要安装git,破解源代码或模拟git可执行文件.如果你选择后者,对于初学者你需要伪造’git config remote.origin.url’,这在pip.vcs.git.Git.get_url被称为(并失败).

希望有所帮助,即使它不是肯定的. 总结

以上是内存溢出为你收集整理的python – pip尝试在未安装git时使用git全部内容,希望文章能够帮你解决python – pip尝试在未安装git时使用git所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1193016.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-03
下一篇2022-06-03

发表评论

登录后才能评论

评论列表(0条)

    保存