I am trying to figure out a way to call wget from my python script on a windows machine. I have wget installed under /bin on the machine. Making a call using the subprocess or os modules seems to raise errors no matter what I try. I'm assuming this is related to the fact that I need to route my python system call through minGW so that wget is recognized.
Does anyone know how to handle this?
Thanks
There's no such thing as under "MinGW". You probably mean under MSYS, a Unix emulation environment for Windows. MSYS makes things look like Unix, but you're still running everything under Windows. In particular MSYS maps /bin
to the drive and directory where you install MSYS. If you installed MSYS to C:\MSYS
then your MSYS /bin
directory is really C:\MSYS\bin
.
When you add /bin
to your MSYS PATH
environment variable, MSYS searches the directory C:\MSYS\bin
. When you add /bin
to the Windows PATH
environment using the command SETX
, Windows will look in the \bin
directory of the current drive.
Presumably your version of Python is the standard Windows port of Python. Since it's a normal Windows application, it doesn't interpret the PATH
environment variable the way you're expecting it to. With /bin
in the path, it will search the \bin
directory of the current drive. Since wget
is in C:\MSYS\bin
not \bin
of the current directory you an error when trying to run it from Python.
Note that if you run a Windows command from the MSYS shell, MSYS will automatically convert its PATH
to a Windows compatible format, changing MSYS pathnames into Windows pathnames. This means you should be able to get your Python script to work by running Python from the MSYS shell.