Including a directory using Pyinstaller
how to use pyinstaller
pyinstaller include modules
pyinstaller --onefile not working
pyinstaller config file
pyinstaller missing module
pyinstaller multiple files
All of the documentation for Pyinstaller talks about including individual files. Is it possible to include a directory, or should I write a function to create the include array by traversing my include directory?
I'm suprised that no one mentioned the official supported option using
Using Spec Files, That file is stored in the --specpath= directory, by default the current directory. When you want to include run-time libraries ( .dll or .so files) that PyInstaller does I 'm trying to include a folder containing phantomjs in my exe I' making with Pyinstaller. I' using this code: Tree('phantomjs-1.9.8-windows'), My spec file is in the same directory with phantomjs fol
Paste the following after
a = Analysis() in the spec file to traverse a directory recursively and add all the files in it to the distribution.
##### include mydir in distribution ####### def extra_datas(mydir): def rec_glob(p, files): import os import glob for d in glob.glob(p): if os.path.isfile(d): files.append(d) rec_glob("%s/*" % d, files) files =  rec_glob("%s/*" % mydir, files) extra_datas =  for f in files: extra_datas.append((f, f, 'DATA')) return extra_datas ########################################### # append the 'data' dir a.datas += extra_datas('data')
Including a directory using Pyinstaller, I'm suprised that no one mentioned the official supported option using Tree() : https://stackoverflow.com/a/20677118/2230844. If you share the same home directory on multiple platforms, for example GNU/Linux and OS X, you will need to set the PYINSTALLER_CONFIG_DIR environment variable to different values on each platform otherwise PyInstaller may cache files for one platform and use them on the other platform, as by default it uses a subdirectory of your home directory as its cache location.
What about just using
from glob import glob datas =  datas += glob('/path/to/filedir/*') datas += glob('/path/to/textdir/*.txt') ... a.datas = datas
Using PyInstaller to Easily Distribute Python Applications – Real , In this step-by-step tutorial, you'll learn how to use PyInstaller to turn your tells PyInstaller to include the version.txt file in the importlib_resources folder in a To check whether your PyInstaller package works, navigate to the directory containing the bundled executable and run the .exe file there from the command line. If it fails to run, the errors you
The problem is easier than you can imagine
hope it helps !!!
How to include folder in exe with Pyinstaller?, I 'm trying to include a folder containing phantomjs in my exe I' making with Pyinstaller. I' using this code: Tree('phantomjs-1.9.8-windows'), My PyInstaller can be used to create.exe files for Windows,.app files for Mac, and distributable packages for Linux. Optionally, it can create a single file which is more convenient for distributing, but takes slightly longer to start because it unzip itself.
Yes, you can just add directories to the Analysis object and they get copied across.
a = Analysis(['main.py'], datas = [('test/dir', 'test/dir')], ...)
[PDF] PyInstaller Documentation, Then it collects copies of all those files – including the active Python interpreter! – and puts them with your script in a single folder, or optionally It turns out that the DataFunctions.py file was included in the .exe, however some file paths relative to the DataFunctions.py file inside it were not set correctly due to the .exe being created in another folder. If anyone else is having similar problems, make sure you don't specify -w so that you can use the console to debug your .exe.
PyInstaller Tutorial, Build the .exe, .app, or linux executable distribution pyinstaller hello.py For example, to include all .ui files in your templates/ directory in to a As the selected answer didn't work for the case of using libportaudio64bit.dll, I put my working solution here. For me, the working solution is to add _sounddevice_data folder where the .exe file is located then making a portaudio-binaries folder in it and finally putting libportaudio64bit.dll in the recently created folder. Hope it helps!
how to add data files with pyinstalled, And if PyInstaller completes, as I said, go into the dist/myscript folder BTW just to keep from confusing yourself, you should always include the Using sys._MEIPASS does not work for one-file executables. From the docs: For a one-folder bundle, this is the path to that folder, wherever the user may have put it. For a one-file bundle, this is the path to the _MEIxxxxxx temporary folder created by the bootloader . Use sys.executable for one-file executables. – Max Tet Jul 12 '18 at 10:26
How do I use Pyinstaller to include helper files? : learnpython, I want to make an executable that is a PyQt5 application, but that application makes use of images found in a folder in the same directory and a data file in the pyinstaller.exe --onefile --icon='Loco.ico program.py In the program, I include an image in my plots, and when I run the program alone in its folder, I get the following: IOError: [Errno 2] No such file or directory: 'Logo.png' One solution is to include the image in the folder of the exe as seen in the link below:
- Thank you for sharing, using the Tree class solved it for me in an elegant way. Now I just need this one line:
a.datas += Tree('./dir_to_include', prefix='dir_to_include')
- yep, I think it is just not documented well-enough, but this open-source, so PRs are welcome :)
- Excuse me, but I don't really get it. I have a directory called
~/Scripts. My data is stored in
~/Scripts/Data. Should I substitute
a.datas += extra_datas('data')by
a.datas += extra_datas('Data')?
- If your pyInstaller script is also in
Scriptsand you call it with
python mybuildscript.pyfrom within
Scriptsthen yes, you should substitute with
Data, otherwise use
..to navigate the directory tree.