如何将gitpython添加到路径

如何将gitpython添加到路径

我已经在linux中安装了gitpython模块。在尝试导入它时,我收到以下错误。

>>> import git
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.7/site-packages/git/__init__.py", line 82, in <module                                                                                                                                                             >
    refresh()
  File "/usr/lib64/python2.7/site-packages/git/__init__.py", line 73, in refresh
    if not Git.refresh(path=path):
  File "/usr/lib64/python2.7/site-packages/git/cmd.py", line 292, 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

我发现

>>> git.__file__
'/usr/lib64/python2.7/site-packages/git/__init__.pyc'

我尝试将其添加到 .profile

作为

$GIT_PYTHON_GIT_EXECUTABLE=/usr/lib64/python2.7/site-packages/git/__init__.py

但它不起作用,请建议

相关内容