AlexShkarin / pyLabLib

Python package for device control and experiment automation
http://pylablib.readthedocs.io
GNU General Public License v3.0
125 stars 28 forks source link

Pyinstaller Executable Crashing #84

Closed dimitrisspacecode closed 2 months ago

dimitrisspacecode commented 2 months ago

I noticed that the pylablib library does not work, it essentially crashes when used with pyinstaller. Specifically the reason it crashes is the program is unable to find the pyvisa version and crashes with the error :

TypeError: '>' not supported between instances of 'str' and 'int'

Now just to clarify this is not only related to pylablib and therefore I do not expect it to be fixed from pylablib. It occurs because pyinstaller does not import the metadata of packages and therefore the version of pyvisa returns 'unknown' instead of the actual version.

For those struggling with the same error, you can add the metadata of pyvisa on the datas array in the .spec file and it will work just fine. An example of this solution is this :

datas=[(r'C:\path-to-python-env\Lib\site-packages\PyVISA-1.14.1.dist-info', 'pyvisa.dist-info')],

I hope this helps whoever stumbles upon the exact same issue as me!