python调用git出错的解决
python调用git出错
#报错信息
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Python27\lib\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环境变量设置问题 #简便解决办法:在导入包的上方增加以下代码 import os os.environ["GIT_PYTHON_REFRESH"] = "quiet"
python版本不当造成git不能使用
1,git错误(原因是python3软链接由python3.6修改为python3.8了)
root@zjx:/work/share/01-mypipeline# git clone https://gitee.com/ilovevenus/mypipeline.git
Traceback (most recent call last):
File "/usr/lib/command-not-found", line 27, in <module>
from CommandNotFound.util import crash_guard
ModuleNotFoundError: No module named 'CommandNotFound'
2,查看python安装情况
root@zjx:/work/share/01-mypipeline# ll /usr/bin/python*
lrwxrwxrwx 1 root root 9 4月 16 2018 /usr/bin/python -> python2.7*
lrwxrwxrwx 1 root root 9 4月 16 2018 /usr/bin/python2 -> python2.7*
-rwxr-xr-x 1 root root 3624880 7月 1 23:56 /usr/bin/python2.7*
lrwxrwxrwx 1 root root 22 9月 29 15:12 /usr/bin/python3 -> /work/py/bin/python3.8*
-rwxr-xr-x 1 root root 4526456 11月 7 2019 /usr/bin/python3.6*
-rwxr-xr-x 1 root root 4526456 11月 7 2019 /usr/bin/python3.6m*
lrwxrwxrwx 1 root root 10 9月 29 14:14 /usr/bin/python3m -> python3.6m*
3,删除软链接并重新设置软链接,问题解决
root@zjx:/work/share/01-mypipeline# rm /usr/bin/python3
root@zjx:/work/share/01-mypipeline# ln -s /usr/bin/python3.6 /usr/bin/python3
root@zjx:/work/share/01-mypipeline# python3
Python 3.6.9 (default, Nov 7 2019, 10:44:02)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
相关文章
Macbook安装Python最新版本、GUI开发环境、图像处理、视频处理环境详解
这篇文章主要介绍了Macbook安装Python最新版本(3.6.4)、GUI开发环境、图像处理、视频处理环境详解,需要的朋友可以参考下2020-02-02Python中dumps与dump及loads与load的区别
这篇文章主要介绍了Python中dumps与dump、loads与load的区别,json模块提供了一种很简单的方式来编码和解码JSON数据。其中两个主要的函数是json.dumps()和json.loads(),需要的朋友可以参考下2022-04-04Python利用逻辑回归模型解决MNIST手写数字识别问题详解
这篇文章主要介绍了Python利用逻辑回归模型解决MNIST手写数字识别问题,结合实例形式详细分析了Python MNIST手写识别问题原理及逻辑回归模型解决MNIST手写识别问题相关操作技巧,需要的朋友可以参考下2020-01-01
最新评论