4

I am a beginner in python. I have written the following python code:

import subprocess
PIPE = subprocess.PIPE
process = subprocess.Popen(['git', 'status'], stdout=PIPE, stderr=PIPE, cwd='my\git-repo\path',shell=True)
stdout_str, stderr_str = process.communicate()

print (stdout_str)
print (stderr_str)

Upon execution of the python script, I get the following output:

b''
b'"git" is not recognized as an internal or external command,\r\noperable program or batch file.\r\n' 

I have added '..../git/bin' to my PATH variable, and since then git commands run fine in cmd.exe. Since 'shell=True', I thought this would run too.

I can't seem to get a hold of the issue. Help appreciated.

SK3
  • 63
  • 7
  • I don’t believe you that this code will produce *that* error message. – poke Oct 28 '17 at 20:34
  • @poke yeah I had added results from another thing I tried. Sorry about that. – SK3 Oct 28 '17 at 21:02
  • Did you ever solve this? I ran into the same problem using this as part of a build chain. My script works fine when run on commandline, but as soon as it runs in the build step it can't find it. – TechnoSam Jan 14 '19 at 22:02

2 Answers2

0

Because git add* is not correct. git add * is, however.

Caden Grey
  • 21
  • 11
0

The issue was due to GIT PATH issues. Once, I updated the PATH properly in Windows Environment Variables and restarted CMD, I didn't face this issue. Further info can be found at 'git' is not recognized as an internal or external command

SK3
  • 63
  • 7