miniSeed files could be read in Pycharm,but meet errors when package them with pyinstaller

I write a very simple code with obspy to read miniSeed files and plotting.
the code is listed below:

import obspy
st = obspy.read(‘temp.seed’)
st.plot()

the input fine ‘temp.seed’ is put in the current directory.
This code can run normally under pycharm. But after packaged with pyinstaller, I meet errors
The enviroment I use is : python==3.3.1; pyinstaller==4.2;python==3.8.1;obspy==1.2.2
I use this command to package my code: pyinstaller -c test.py
When completing the package, I copy obspy directory to dist/test directory and run test.exe
The following is the error message:
File “test.py”, line 3, in
File “”, line 2, in read
File “obspy\core\util\decorator.py”, line 300, in _map_example_filename
return func(*args, **kwargs)
File “obspy\core\stream.py”, line 212, in read
st = _generic_reader(pathname_or_url, _read, **kwargs)
File “obspy\core\util\base.py”, line 702, in _generic_reader
generic = callback_func(pathnames[0], **kwargs)
File “”, line 2, in _read
File “obspy\core\util\decorator.py”, line 210, in uncompress_file
result = func(filename, *args, **kwargs)
File “obspy\core\stream.py”, line 256, in _read
stream, format = _read_from_plugin(‘waveform’, filename, format=format,
File “obspy\core\util\base.py”, line 450, in _read_from_plugin
raise TypeError(‘Unknown format for file %s’ % filename)
TypeError: Unknown format for file temp.seed
[10948] Failed to execute script test
I have been confused by this problem for days and tried to use different versions of the package, but failed again and again.
BTW: I also tried to read waveform files of SAC format, meet the same errors, it seems that after packaged by pyinstaller, the obspy can’t read any type of data.
Hope to get helpful instruction here…

packaging obspy with pyinstaller can be tricky: you need to check that the content of the package is properly included in the distribution you are building. ObsPy uses entry_points for declaring I/O routines, which are NOT parsed automatically by pyinstaller, I think.

Hi Thomas,
Many thanks for your quick response. Your comments might help, but I’m still confused now.
As you have seen, my python code is very simple with the purpose of testing how to package it into executable package by pyinstaller, it just includes three lines.
Could you please demonstrate this with a simple example including packaging commands?

Hey,

You have to manually add the entry points to pyinstaller, so that it knows it has to package the obspy.io.mseed for you etc…
thomas

Hey Thomas,

Thank you for the response, which is helpful for understanding. I encountered the same problem: code runs in vs code, but meet errors when packaged with pyinstaller. Could you please elaborate more on how to manually add the entry points to pyinstaller? Is it by modifying the spec file?

See SEGY Format Unrecognized After Packaging with PyInstaller or cx_Freeze · Issue #3366 · obspy/obspy · GitHub for similar questions