2

I have a MyApp.spec files where I have:

a = Analysis(...
datas=[
       ('file_1.jpg', '.', 
       ('file_2.mplstyle', '.'),
      ]
...)

In my code, these files are used in methods as, for example, plt.style.use('file_2.mplstyle') (python files and such extra files are in the same folder).

I compile my code with pyinstaller --onefile MyApp.spec and it yields no error.

However, at execution time, the file_2.mplstyle is not found.

So far, the only trick for the execution to succeed is to manually copy both files to the dist/ directory.

floflo29
  • 2,261
  • 2
  • 22
  • 45

1 Answers1

1

your pyplot command assumes the file is in the same directory, where as you, correctly, install it to a separate one.

You need to use the file from where you've installed it!

Bundling data files with PyInstaller (--onefile) tells you how to find the file in the installed location.

Marcus Müller
  • 34,677
  • 4
  • 53
  • 94