I need to create a windows batch script which creates and moves one specific file to PYTHONPATH\Lib\distutils
folder.
Here is what I am attempting to do:
ECHO [build] >> distutils.cfg
ECHO compiler=mingw32 >> distutils.cfg
MOVE distutils.cfg PYTHONPATH\Lib\distutils
However, PYTHONPATH
does not exist but I know that Python location is set in PATH
which I can check.
How can I parse PATH
and extract Python location from it?
Since python is in your PATH
you can use function where
, which is a Windows analogue of Linux whereis
function:
> where python.exe
See details here. You can set output of where
command to a variable and then use it (see this post).
If you have only one python
instance, you can try this:
@ECHO OFF
FOR /f %%p in ('where python') do SET PYTHONPATH=%%p
ECHO %PYTHONPATH%
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With