您尚未登录。

楼主 #1 2019-11-26 08:32:41

鱼与熊掌
会员
注册时间: 2019-11-26
已发帖子: 5
积分: 5

试一试Python3调用git命令

安装:

sudo apt-get install python3-pip -y 

python3 -m pip install python-git

奇怪了,还是不能import git:

root@test5:/opt# python3
Python 3.6.8 (default, Oct  7 2019, 12:59:55)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import git
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'git'
>>>
>>>
>>>
>>> quit()

离线

楼主 #2 2019-11-26 08:38:30

鱼与熊掌
会员
注册时间: 2019-11-26
已发帖子: 5
积分: 5

Re: 试一试Python3调用git命令

原来是用错了pip包, 重新来一次:

sudo apt-get install python3-pip -y 

python3 -m pip install  gitpython

https://github.com/gitpython-developers/GitPython

这次 import 正常了。

离线

楼主 #3 2019-11-26 09:04:59

鱼与熊掌
会员
注册时间: 2019-11-26
已发帖子: 5
积分: 5

Re: 试一试Python3调用git命令

import git

git.Git("/opt/").clone("https://github.com/torvalds/linux/")

python3 克隆搞定.

离线

#4 2019-11-26 09:29:35

fogwizard
会员
注册时间: 2019-03-19
已发帖子: 50
积分: 8

Re: 试一试Python3调用git命令

这个功能好

离线

#5 2019-11-26 09:32:10

aozima
会员
所在地: 深圳
注册时间: 2019-05-25
已发帖子: 451
积分: 318.5
个人网站

Re: 试一试Python3调用git命令

和直接调用git命令的区别和优势在哪里???

最近编辑记录 aozima (2019-11-26 09:32:19)

离线

楼主 #6 2019-11-26 09:51:42

鱼与熊掌
会员
注册时间: 2019-11-26
已发帖子: 5
积分: 5

Re: 试一试Python3调用git命令

aozima 说:

和直接调用git命令的区别和优势在哪里???

受晕哥委托, whycan积分兑换下载码,凭码提交github的下载链接,服务器自动克隆/压缩/邮件私发下载地址。

离线

#7 2019-11-27 11:29:02

aozima
会员
所在地: 深圳
注册时间: 2019-05-25
已发帖子: 451
积分: 318.5
个人网站

Re: 试一试Python3调用git命令

好吧  666

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn