Search code examples
pythoninstallationpippackagepywin32

How to install pip package files instead of the command `pip install`


I have a python program that executes os.system("pip install pywin32") but for some reason it doesn't install it. So if it's possible to put the files of the pywin32 package in the working directory then no need to execute os.system("pip install pywin32") and the package would be already downloaded.

Anyone knows how to do that?


Solution

  • To do so, we should at first convert the python program to an executable (.exe) using pyinstaller with the command:

    pyinstaller myFile.py --noconfirm --onefile --console --icon=icon.ico --name myName you can find more options in the pyinstaller docs.

    Then this executable file that has been created will detect all the packages that has been imported in the initial python program and will install them when the executable is ran for the first time.

    If you wish to store packages that hasn't been imported in the initial python file use the option --hidden-import <Package Name> to your conversion command.