简体   繁体   中英

'git' is not recognized as an internal or external command, operable program or batch file even after adding to PATH

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM