python - 我想问如何解决这个问题
问题描述
Traceback (most recent call last):
File "/home/shi/anaconda3/lib/python3.6/site-packages/git/__init__.py", line 83, in <module>
refresh()
File "/home/shi/anaconda3/lib/python3.6/site-packages/git/__init__.py", line 73, in refresh
if not Git.refresh(path=path):
File "/home/shi/anaconda3/lib/python3.6/site-packages/git/cmd.py", line 290, in refresh
raise ImportError(err)
ImportError: Bad git executable.
The git executable must be specified in one of the following ways:
- be included in your $PATH
- be set via $GIT_PYTHON_GIT_EXECUTABLE
- explicitly set via git.refresh()
All git commands will error until this is rectified.
This initial warning can be silenced or aggravated in the future by setting the
$GIT_PYTHON_REFRESH environment variable. Use one of the following values:
- quiet|q|silence|s|none|n|0: for no warning or exception
- warn|w|warning|1: for a printed warning
- error|e|raise|r|2: for a raised exception
Example:
export GIT_PYTHON_REFRESH=quiet
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "github-scraper/scraper.py", line 5, in <module>
from PyRepo import PyRepo
File "/home/shi/PycharmProjects/pycodesuggest-master/github-scraper/PyRepo.py", line 2, in <module>
from git import Repo
File "/home/shi/anaconda3/lib/python3.6/site-packages/git/__init__.py", line 85, in <module>
raise ImportError('Failed to initialize: {0}'.format(exc))
ImportError: Failed to initialize: Bad git executable.
The git executable must be specified in one of the following ways:
- be included in your $PATH
- be set via $GIT_PYTHON_GIT_EXECUTABLE
- explicitly set via git.refresh()
All git commands will error until this is rectified.
This initial warning can be silenced or aggravated in the future by setting the
$GIT_PYTHON_REFRESH environment variable. Use one of the following values:
- quiet|q|silence|s|none|n|0: for no warning or exception
- warn|w|warning|1: for a printed warning
- error|e|raise|r|2: for a raised exception
Example:
export GIT_PYTHON_REFRESH=quiet
解决方案
我认为该消息非常明确地说明了正在发生的事情:git 不在 PATH 中。抱怨的 python 脚本可能正在调用运行“git”。为了使其正常工作,git 可执行文件的目录必须作为目录包含在PATH
. 如果不是,那么调用将惨遭失败。另一种可能性是通过设置另一个环境变量(GIT_PYTHON_EXECUTABLE),您可以在其中指定 git 可执行文件本身的位置,如果它不在 PATH 中并且您不想弄乱 PATH 变量。
推荐阅读
- twitter-bootstrap - 打开引导模式并根据点击事件滚动到特定的div(动态jquery)
- javascript - 如何在 React Native 项目中添加依赖项
- r - xts 对象中月份数据的平均值(1 月至 12 月)
- python - 一个特定的变量没有定义我不知道为什么
- python - Python中的字符串到JSON
- android - 在android中的某些条件下,如何以编程方式设置按钮的背景?
- c - 调试密码复杂性检查器
- python - 创建一个 B 列,将组的总和存储在 A 列中,但仅在特定值处
- r - 为什么我无法正确绘制模型选择图?
- google-oauth - idpiframe_initialization_failed with People Api