Failure when using the neo package in a pyinstaller executable

30 views
Skip to first unread message

sebastian.oltm...@gmail.com

unread,
Jan 11, 2019, 6:21:43 AM1/11/19
to Neural Ensemble
First of all, thanks for making this package. I enjoy reading about it and think it's very good.

Now, let me tell you what I found out using the python neo package.

I am working on a project for optical electrophysiology and want to combine that with normal electrophysiology. For combining that, I want to import .abf files. Searching for a package that can import these files, I found the neo project. In the end, the only lines in my project that use neo are:

from neo.io import AxonIO

abf_reader
= AxonIO(filepath)
abf_seg
= abf_reader.read_segment()
data
= np.array([d[0] for d in abf_seg.analogsignals[0].rescale('mV').magnitude])

These lines worked perfectly when I tested everything running it with the python enviroment. But once I created an executable using pyinstaller, and executed this executable, the line after the import fails. This is the error:

Traceback (most recent call list):
  File "foo\bar.py", line ..., in ...
  File "site-packages\neo\io\axonio.py", line 45, in __init__
  File "site-packages\neo\io\basefromrawio.py", line 73, in __init__
  File "site-packages\neo\rawio\baserawio.py", line 152, in parse_header
  File "site-packages\neo\rawio\baserawio.py", line 382, in _group_signal_channel_characteristics
ModuleNotFoundError: No module named 'numpy.lib.recfunctions'
 
I do not understand why that error occurs. I checked in the neo source code and did not find any occurence of numpy.lib.recfunctions.

In the end, I fixed the error with a, in my opinion, not so nice workaround: I just added

import numpy.lib.recfunctions

in my code somewhere.

I do not know if this is a bug regarding pyinstaller, neo, or maybe just a strange interaction between these two. But I wanted to share my experience and give a workaround. Maybe, one should add the line I added somewhere in the neo code to avoid that kind of bug for other people.

Samuel Garcia

unread,
Jan 11, 2019, 6:58:23 AM1/11/19
to neurale...@googlegroups.com
Hi Sebastian,
To avoid to stack each signal you can also

abf_seg = abf_reader.read_segment(signal_group_mode='group-by-same-units')
data = abf_seg.analogsignals[0].rescale('mV').magnitude

In that case, abf_seg.analogsignals[0] is already 2D with all channel.



For pyinstaller, I already used it in the past.
I remember that you must activate some "hook" for complicated package (aka not pure python).
Python installer already propose a long list of hook. Numpy must already in this list.

Are able to freeze a simple package with PyInstaller that have only numpy dependency ?
Maybe should ask directly at pyinstaller list.
Maybe also pyinstaller is not able to detect that neo dependend on numpy and quantity, so you should make an explicit import  numpy, quantity somewhere in your code.


Samuel
--
You received this message because you are subscribed to the Google Groups "Neural Ensemble" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neuralensembl...@googlegroups.com.
To post to this group, send email to neurale...@googlegroups.com.
Visit this group at https://groups.google.com/group/neuralensemble.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages