2

How to install Python libraries using Pip (for instance requests, jinja2, falcon etc)** in Inno Setup?

I know one method to install Python libraries using Pip in Inno Setup (just a sample code in the below):

Inno Setup file:

[Files]
FileName: "python_file.py";

python_file.py

import subprocess
subprocess.call(["pip", "install", "requests"])

May I know, is there any other way to install Python libraries using Pip in Inno Setup?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
user2224250
  • 251
  • 1
  • 8
  • 19

1 Answers1

2

As the pip is a standalone executable, you can execute it as any other executable using the [Run] section:

[Run]
Filename: "pip.exe"; Parameters: "install requests"; StatusMsg: "Installing requests..."
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • Thanks, I believe, the above work flow should work. In my case, unfortunately, while installing the setup file, Inno unable to pick python & pip path. However, when I type python, pip in CMD, it responds properly. Do you have any idea ?. It would be really appreciable.. My Run Section as follows: [Run] FileName: "msiexec.exe"; Parameters: "here python msi file"; Flags: waitunitlterminated ------------------ FileName: "python.exe"; Parameters: "{app}\get-pip.py"; Flags: waitunitlterminated ------------------- FileName: "pip.exe"; Parameters: "install requests"; Flags: waitunitlterminated – user2224250 Feb 09 '17 at 08:09
  • And if you run the `cmd` as Administrator, is `pip` found? (i mean manually, not from Inno Setup) – Martin Prikryl Feb 09 '17 at 08:19
  • if i run cmd (with out admin), pip found – user2224250 Feb 09 '17 at 08:34
  • Am getting the following error while installing setup file: Unable to execute file: C:\Python\Scripts\pip.exe CreateProcess failed;code2. The system cannot find the file specified – user2224250 Feb 09 '17 at 08:42
  • Am sorry..I am trying different Inno versions. The current version is unable to find pip in CMD – user2224250 Feb 09 '17 at 08:49
  • *"if i run cmd (with out admin), pip found"* - I've asked you if it is found, when you run the `cmd` **as admin**. – Martin Prikryl Feb 09 '17 at 08:51
  • No, Pip Not found – user2224250 Feb 09 '17 at 08:53
  • 1
    That the Python is not added to the global `PATH`. Does the `pip` require administrator privileges? If not, you can use `Flags: runasoriginaluser` - Or use a full path to the `python` and `pip`. – Martin Prikryl Feb 09 '17 at 08:56
  • I am very new to Innosetup..please guide, if am doing wrong....In the [Registry] Section: I have added the python path with the following syntax** Root: HKLM; Subkey: "System\.....\Session Manager\Environemnt ValueName:PATH; ValueData:{oldData};C:\Python34;C:\Python34\Scripts"** – user2224250 Feb 09 '17 at 09:04
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/135248/discussion-between-user2224250-and-martin-prikryl). – user2224250 Feb 09 '17 at 09:17
  • Flags: runasoriginialuser did the trick..Cool.thank you Martin – user2224250 Feb 09 '17 at 09:21
  • The `[Registry]` entry won't by default help for the existing processes (and new subprocesses of existing processes) - See http://stackoverflow.com/q/21708140/850848 - Though if you use a fixed path to the Python, you can use it straight away in the the `[Run]` section too. – Martin Prikryl Feb 09 '17 at 09:32