1

I'm trying to install python and 1 pypi module programmatically via a batch script, to allow me to run a script I wrote that needs that module, on several PCs. A batch script will make it easier to install. I have tried

    \\server\share\python-3.6.1.exe /quiet InstallAllUsers=1 Include_pip=1 Include_test=0 PrependPath=1
    python -m pip install utm
    pause 

Without success. When run, this throws the error ‘python’ is not recognized as an internal or external command. I realize this means the system path variables have not been updated correctly, but I thought PrependPath=1 was setting these variables correctly. Any help anyone could provide would be appreciated.

1
  • 1
    You have to close cmd and open a new instance of cmd to get the new PATH value. Commented Jul 10, 2017 at 22:16

1 Answer 1

3

PrependPath will add to the path, you have to re-read the path again in order for the command to work.

You can re-read the path by using RefreshEnv.cmd from chocolatey, or simply customize the path for the installation, and then pass the full path to the Python executable, like this:

\\server\share\python-3.6.1.exe /quiet InstallAllUsers=1 TargetDir=%ProgramFiles%\Python3.6 Include_pip=1 Include_test=0 PrependPath=1
%ProgramFiles%\Python3.6\python.exe -m pip install utm
Sign up to request clarification or add additional context in comments.

5 Comments

This almost worked. However, it installed python in C:\program\ and gave me the error message C:\program is not a recognized command.
Ah of course, Windows. You can try running the command via PowerShell, or simply use a non-spaced path, like TargetDir=C:\Python\Python3.6
Thanks! I really appreciate it. I'll test this later tonight then mark it as solved.
Worked like a charm. Thank you very much for your help.
Or just add the required quotes, e.g. set "TARGETDIR=%ProgramFiles%\Python3.6" and install to TargetDir="%TARGETDIR%" and run "%TARGETDIR%\python.exe" -m pip install utm.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.