1

I've been using pyinstaller to create Mac applications that utilize the mne package for EEG signal analysis. Until the most recent update of mne, everything worked fine.

However, now during the process of building my app,I'm encountering the error,

No such file or directory: 
'/dist/MyApp.app/Contents/MacOS/mne/report/js_and_css/report.js'

The error persists when I try to run the unix executable from the command line. I can see report.js within the mne module directory, and I've tried to modify my .spec file so that pathex includes the directory containing report.js':

'/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/mne/report/js_and_css/report.js'

However, this does not solve the problem. How can I get pyinstaller to find the location of report.js during the build process?

fishbacp
  • 1,123
  • 3
  • 14
  • 29

2 Answers2

0

I might have had the same issue. I had to add the full mne directory to make it work (it might not be the best option...).

I followed the doc to use the pyinstaller spec file. I modified the spec file:

a = Analysis(['main.py'],
             [...]
             datas=[], # HERE
             [...])

to

a = Analysis(['main.py'],
             [...]
             datas=[("path/to/venv/Lib/site-packages/mne", "mne")], # HERE
             [...])

If you do not work in a venv, you might need adapt the path.

Note
It seems to be other ways of Including a directory using Pyinstaller. I did not try them, but I can tell the using spec file works.
EDIT: I tried with the option --add-data="relative/path/to/mne;mne", it works like a charm.

Note 2
This answer is a workaround, not a solution. I guess mne should be imported correctly without to use this workaround, but I don't know more.

etiennedm
  • 409
  • 1
  • 3
  • 9
  • @ethttps://stackoverflow.com/users/6488052/etiennedm The ```collect_data_files``` ended up being an efficient way for me to collect all the needed data files: ```from PyInstaller.utils.hooks import collect_data_files data=collect_data_files('mne')``` Now, other data can be appended to the above and the result can be included in the ```Analysis``` instance. – fishbacp Feb 16 '22 at 16:08
0

@ethttps://stackoverflow.com/users/6488052/etiennedm

The collect_data_files ended up being an efficient way for me to collect all the needed data files:

from PyInstaller.utils.hooks import collect_data_files
data=collect_data_files('mne')

Now, other data can be appended to the above and the result can be included in the Analysis instance.

fishbacp
  • 1,123
  • 3
  • 14
  • 29