shutil.which() not finding programs without appending file extension

强颜欢笑 提交于 2019-12-11 07:26:38

问题


Trying to use shutil.which() to determine if git is installed. From the docs, I see which() on Windows should use PATHEXT to know which file extensions to append when searching. However the following occurs when using the interpreter:

>>> import os
>>> import shutil
>>> os.getenv('PATHEXT')
'.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;'
>>> shutil.which('git')
>>> shutil.which('git.exe')
'C:\\Program Files\\Git\\cmd\\git.exe'

This is in a virtual environment created using VirtualEnv Wrapper in D:\Envs if that makes any difference.

来源:https://stackoverflow.com/questions/56399696/shutil-which-not-finding-programs-without-appending-file-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!