简体   繁体   English

使用 Inno Setup 安装 Python

[英]Install Python with Inno Setup

I am creating a setup from C# program successfully with Inno Setup.我正在使用 Inno Setup 从 C# 程序成功创建设置。 To run this program I need Python.要运行这个程序,我需要 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.直到今天,我要求我的客户手动安装 Python,因为有些客户并不总是遵循我的安装指南,我经常收到他们的问题。 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 Python的安装路径: C:\\Python\\Python3.5.2
  2. Installation for all users为所有用户安装
  3. Set the global environment variable for Python C:\\Python\\Python3.5.2为 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.不幸的是,正常的 Python 安装正在开始。

[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 BR斯蒂芬

You seem to be using a completely wrong sent of command line arguments (for Windows Installer?).您似乎使用了完全错误的命令行参数发送(对于 Windows 安装程序?)。

See Python documentation for correct command-line arguments of the Python Windows installer:有关 Python Windows 安装程序的正确命令行参数,请参阅 Python 文档:
https://docs.python.org/3/using/windows.html 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. RegValueExists()总是以空值名称返回 false。 That means your check function always returns false even if the key exists.这意味着即使键存在,您的检查函数也始终返回 false。 This is the reason why Python installation is run always, even if Python is already installed.这就是为什么 Python 安装总是运行的原因,即使 Python 已经安装。

To check for the existence of a key, not a value, use the function RegKeyExists() .要检查键是否存在,而不是值,请使用函数RegKeyExists()

See How to check if specific Python version is installed in Inno Setup?请参阅如何检查 Inno Setup 中是否安装了特定的 Python 版本?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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