Home > database >  How to make a Python exe file automatically install dependancies?
How to make a Python exe file automatically install dependancies?

Time:03-09

I have made an application (exe file) using python using some libraries installed as needed on the go. Now I want to make it usable for person who doesn't know how to install dependancies and which ones are needed. What to do to transform it into an easy to use application and probably make it able to run on Mac too??

Please suggest some resources that might help me know more.

CodePudding user response:

PyInstaller might be something you are looking for, which can create .exe files from python scripts.

Here's the documentation. Be aware that the __import__() function with variable data isn't detected by PyInstaller, so you should just use import ..., and then PyInstaller will add the dependencies so that they are used in the .exe file.

CodePudding user response:

As Wouter K mentioned, you should install Pyinstaller (pip install pyinstaller for pip) and then cd to the directory you want and type pyinstaller --onefile file.py on the terminal. If you cded in the directory your file is, you just type the name and the extension (.py) of your file. Else, you will have to specify the full path of the file. Also, you can't make an mac os executable from a non mac os pc. You will need to do what I mentioned above on a mac.

  • Related