Python and pip installation during setup via batch file

Issue

This Content is from Stack Overflow. Question asked by yst_

I’m currently setting up the installer for a tool I wrote, that utilizes another small python tool, which i need to install via pip.
I do this by running a batch-file during the setup.
(I use InnoSetup for my installer)

Now…the Python installation works no-problem, but afterwards the commandline still thinks that python is not installed and thus cannot interpret the “pip”-command.

I’ve already tried restarting the commandline, aswell as putting the pip-command in a different file alltogether, which gets called after the first one.
None of that had any positive results.

The only idea i have left is restarting the PC during the setup, but i’d really like to avoid that. (I’ll try it after this post and let you know if it worked)

So, if anyone has some input, how I could achieve that, i’ll gladly try it.

Here is the (current) code of my batch file:

python --version 2>NUL
IF %ERRORLEVEL% EQU 0 GOTO INSTOLE

ECHO.
ECHO oleidUI requires a valid Python-Installation
ECHO.
:INSTPY
SET /p answer=Do you want to run the Setup for Python v.3.10.7 now? Y / N 
IF /i %answer:~,1% EQU Y GOTO :PYSETUP
IF /i %answer:~,1% EQU N GOTO :NOPYTHO
ECHO [Y]es / [N]o
GOTO INSTPY

:PYSETUP
ECHO.
ECHO python-3.10.7-amd64.exe will start now
START /WAIT python-3.10.7-amd64.exe
START install.bat

:INSTOLE
pip install -U oletools[full]
IF %ERRORLEVEL% GTR 1 GOTO NOPYTHO
PAUSE
EXIT

:NOPYTHO
ECHO After installing Python please run [Installation Folder]oleidUiresourcesappSetupinstall.bat to finalize the installation of oleidUI
PAUSE
EXIT



Solution

This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?