简体   繁体   中英

Install Python with Inno Setup

I am creating a setup from C# program successfully with Inno Setup. To run this program I need Python. Until today I asked my customers to install Python manually, since some customers are not always following my installation guide, I am getting often questions from them. Now I want to simplify the installation, so that everything is done automatically. I need to set:

  1. Install path of Python: C:\\Python\\Python3.5.2
  2. Installation for all users
  3. Set the global environment variable for Python C:\\Python\\Python3.5.2
  4. If all this already exist no installation needed

I tried to do this with this code, but I didn't had any success. Normal Python installation is starting unfortunately.

[Run]
Filename: "{app}\deploy\python-3.5.2.exe"; \
    Parameters: "/i ""C:\Python\Python-3.5.2"" /qb! ALLUSER=1 ADDLOCAL=ALL"; \
    WorkingDir: "{app}\deploy"; Flags: 32bit; Check: python_is_installed

[Code]

function python_is_installed() : Boolean;
var
  key : string;
begin
   { check registry }
   key := 'software\Python\Python-3.5.2\InstallPath';
   Result := not RegValueExists(HKEY_LOCAL_MACHINE, Key, '');  
end;

What do I do wrong?

BR Stefan

You seem to be using a completely wrong sent of command line arguments (for Windows Installer?).

See Python documentation for correct command-line arguments of the Python Windows installer:
https://docs.python.org/3/using/windows.html


You probably want something like this:

/passive InstallAllUsers=1 TargetDir=C:\Python\Python3.5.2 PrependPath=1

Another problem is that the installation check in the code section is not working as expected. RegValueExists() always returns false with an empty value name. That means your check function always returns false even if the key exists. This is the reason why Python installation is run always, even if Python is already installed.

To check for the existence of a key, not a value, use the function RegKeyExists() .

See How to check if specific Python version is installed in Inno Setup?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM