1

When I am trying to converting my python file into executable and binding with pdf with using command add-data. My pdf file is store no where due to this I cannot open my pdf file while opening executable.(yes, but command will create executable properly but there storing of pdf in default temp directory).

command:

pyinstaller.exe --add-data src;. --onefile python_file.py

P.s:- I tried to popen my file through my code but pdf is storing nowhere so, I cannot execute popen command

eyllanesc
  • 235,170
  • 19
  • 170
  • 241

1 Answers1

0

The documentation of pyinstaller is here: https://pyinstaller.readthedocs.io/en/stable/usage.html and syntax of this command is:

--add-data <SRC;DEST or SRC:DEST>
    Additional non-binary files or folders to be added to the executable. The path 
separator is platform specific, os.pathsep (which is ; on Windows and : on most unix 
systems) is used. This option can be used multiple times.

It means that for each folder of data you need use this parameter once. SRC is path in your system. DST is path relative to your bundle root. I suggest do not use --onefile when you have some problem with build. Then you can easier inspect resulted build.

Grzegorz Bokota
  • 1,736
  • 11
  • 19
  • I tried to run above program without --onefile and knows how basically add data function works but tell me, can we build whole dir of add-data(script_dir) into single executable – divyansh jain Aug 18 '19 at 11:35
  • You do not show your code. Some times ago the onefile option create self extracting archive. On start it is extracted to some temp directory. So if you include your data to bundle it should be in this temp dir (not on macos). The problem could not be in pyinstaller but in method how you try to access to your data. Maybe you need to calculate path relative to some inner file instead of executable. – Grzegorz Bokota Aug 18 '19 at 12:24
  • I'm messed up.Basically, I want to Bind pdf with my script and I did this using command --add-data src;.(destination) when run this command without using one file I found that pdf is stored in dest/script_name/ but I want to know when I use command --onefile where my file is being stored?? As, you said that earlier version (3.3.1)onefile created self extracting archive(temp_dir) but now when I open temp there been is no file appear due to that I'm not Able to access my data. Are you want to say that I need to store pdf in some inner path(dest/script_name/so_on) and run pdf from my script? – divyansh jain Aug 18 '19 at 14:47
  • https://pyinstaller.readthedocs.io/en/stable/operating-mode.html#how-the-one-file-program-works - the docs says that it still works in this way. Which system you use? – Grzegorz Bokota Aug 18 '19 at 15:46
  • Finally , I found error, which is in my code i.e. You are right. Command subprocess.popen() open my files but due to my whole script get executed,files from temp_dir is been removed which causes error in opening of that file – divyansh jain Aug 19 '19 at 02:17