Search code examples
pythonpython-3.xanacondapyinstallerexecutable

Pyinstaller onedir option - exe file outside the directory


Recently I was experimenting with pyinstaller to create an executable file from my Python script. Everything works as expected. I tested two options: --onefile, which takes quite a long time (like 20-30sec) to start because it depacks everything into a temporary directory. The --onedir option is much faster (4sec) to start but it's not very comfortable to use. When I move exe file outside this directory program no longer works. My question is: is there a possibility to make the exe file point to this directory location? I want to keep all the pyinstaller files in one place and allow users to have the exe file in any location they want. Thanks for help.


Solution

  • Let's just see a real-life production case. Whenever you download say a pirated game, or and original copy of software, generally they are compressed together. When you unzip them, a new folder is extracted and inside that folder there are a lot of other folders. What you do to run the software is you simply double click the .exe file.

    Your situation is the same. If you move the exe file outside the original extracted folder then it simply doesn't work. So, the work around way is to create a shortcut to the exe file.

    Hope this clarifies your doubt :)