pyedfread icon indicating copy to clipboard operation
pyedfread copied to clipboard

import error after installation

Open anne-urai opened this issue 1 year ago • 4 comments

Great to see new life in this package!

Unfortunately, we are failing to import (after successful installation) on two different machines.

1. Macbook, EyeLink Dev Kit installed:

installing in base env (first creating dedicated conda env leads to the same issue)

(base) m0043843:~ uraiae$ pip install git+https://github.com/s-ccs/pyedfread
Collecting git+https://github.com/s-ccs/pyedfread
  Cloning https://github.com/s-ccs/pyedfread to /private/var/folders/ly/drwv1q0j4t977rvf2rqyvvq8gsq3lc/T/pip-req-build-zh_glvm7
  Running command git clone --filter=blob:none --quiet https://github.com/s-ccs/pyedfread /private/var/folders/ly/drwv1q0j4t977rvf2rqyvvq8gsq3lc/T/pip-req-build-zh_glvm7
  Resolved https://github.com/s-ccs/pyedfread to commit 475cf0feded65c69cadaa4aa8ec5ed892b8844a3
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting numpy (from pyedfread==0.3.0)
  Using cached numpy-2.1.0-cp312-cp312-macosx_14_0_arm64.whl.metadata (60 kB)
Collecting pandas (from pyedfread==0.3.0)
  Using cached pandas-2.2.2-cp312-cp312-macosx_11_0_arm64.whl.metadata (19 kB)
Collecting h5py (from pyedfread==0.3.0)
  Using cached h5py-3.11.0-cp312-cp312-macosx_11_0_arm64.whl.metadata (2.5 kB)
Collecting python-dateutil>=2.8.2 (from pandas->pyedfread==0.3.0)
  Using cached python_dateutil-2.9.0.post0-py2.py3-none-any.whl.metadata (8.4 kB)
Collecting pytz>=2020.1 (from pandas->pyedfread==0.3.0)
  Using cached pytz-2024.1-py2.py3-none-any.whl.metadata (22 kB)
Collecting tzdata>=2022.7 (from pandas->pyedfread==0.3.0)
  Using cached tzdata-2024.1-py2.py3-none-any.whl.metadata (1.4 kB)
Collecting six>=1.5 (from python-dateutil>=2.8.2->pandas->pyedfread==0.3.0)
  Using cached six-1.16.0-py2.py3-none-any.whl.metadata (1.8 kB)
Using cached h5py-3.11.0-cp312-cp312-macosx_11_0_arm64.whl (2.9 MB)
Using cached numpy-2.1.0-cp312-cp312-macosx_14_0_arm64.whl (5.1 MB)
Using cached pandas-2.2.2-cp312-cp312-macosx_11_0_arm64.whl (11.3 MB)
Using cached python_dateutil-2.9.0.post0-py2.py3-none-any.whl (229 kB)
Using cached pytz-2024.1-py2.py3-none-any.whl (505 kB)
Using cached tzdata-2024.1-py2.py3-none-any.whl (345 kB)
Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Building wheels for collected packages: pyedfread
  Building wheel for pyedfread (pyproject.toml) ... done
  Created wheel for pyedfread: filename=pyedfread-0.3.0-cp312-cp312-macosx_11_0_arm64.whl size=3441241 sha256=aa12c418e2eda7556b777088e1ff6418c0aa13f006f9a1495ad633d05e819078
  Stored in directory: /private/var/folders/ly/drwv1q0j4t977rvf2rqyvvq8gsq3lc/T/pip-ephem-wheel-cache-mrnbu8d1/wheels/71/01/be/6437965794e8879933ae0e9f876a1163814a70d80320f928f9
Successfully built pyedfread
Installing collected packages: pytz, tzdata, six, numpy, python-dateutil, h5py, pandas, pyedfread
Successfully installed h5py-3.11.0 numpy-2.1.0 pandas-2.2.2 pyedfread-0.3.0 python-dateutil-2.9.0.post0 pytz-2024.1 six-1.16.0 tzdata-2024.1

then:

(base) m0043843:~ uraiae$ python
Python 3.12.3 | packaged by Anaconda, Inc. | (main, May  6 2024, 14:46:42) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyedfread
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/miniconda3/lib/python3.12/site-packages/pyedfread/__init__.py", line 3, in <module>
    from pyedfread.parse import read_edf
  File "/opt/miniconda3/lib/python3.12/site-packages/pyedfread/parse.py", line 1, in <module>
    from pyedfread import edf_read
ImportError: dlopen(/opt/miniconda3/lib/python3.12/site-packages/pyedfread/edf_read.cpython-312-darwin.so, 0x0002): Library not loaded: @rpath/edfapi.framework/Versions/A/edfapi
  Referenced from: <9807F4DB-F490-3A45-B3DA-549D3065025D> /opt/miniconda3/lib/python3.12/site-packages/pyedfread/edf_read.cpython-312-darwin.so
  Reason: tried: '/opt/miniconda3/lib/edfapi.framework/Versions/A/edfapi' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/miniconda3/lib/edfapi.framework/Versions/A/edfapi' (no such file), '/opt/miniconda3/lib/edfapi.framework/Versions/A/edfapi' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/miniconda3/lib/edfapi.framework/Versions/A/edfapi' (no such file), '/opt/miniconda3/bin/../lib/edfapi.framework/Versions/A/edfapi' (no such file), '/opt/miniconda3/bin/../lib/edfapi.framework/Versions/A/edfapi' (no such file)
>>> 

2. Windows (after following these instructions)

import pyedfread
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[2], line 5
      2 from pathlib import Path
      3 import numpy as np
----> 5 import pyedfread

File c:\Users\Philippa\miniconda3\envs\iblenv\lib\site-packages\pyedfread\__init__.py:3
      1 """Read eye-tracking information from EyeLink EDF files."""
----> 3 from pyedfread.parse import read_edf
      4 from pyedfread.edf_read import read_preamble, read_messages, read_calibration

File c:\Users\Philippa\miniconda3\envs\iblenv\lib\site-packages\pyedfread\parse.py:1
----> 1 from pyedfread import edf_read
      2 import numpy as np
      3 import pandas as pd

ImportError: DLL load failed while importing edf_read: The specified module could not be found.

Any idea as to what's going wrong in both cases (where the install doesn't throw any errors)?

anne-urai avatar Aug 26 '24 12:08 anne-urai

I finally made some progress here - for some reason in newer python versions, some systempath is not added, and surprisingly, it cannot find python311.dll (on windows).

Image

I'll try to look further later

PS: Linux still works ;-)

behinger avatar Jan 17 '25 08:01 behinger

ok,I think that was a red hering - I now think it has to do with Python3.8 and a change in cython where some paths are not added automatically anymore. In python 3.7 iirc it worked. I'm close I think :D

behinger avatar Jan 17 '25 18:01 behinger

ok at least the windows one is fixed now. For the mac one I draw a blank for now, because I simply have no mac environment available :|

behinger avatar Jan 17 '25 18:01 behinger

I found that if I set the environment variable DYLD_FRAMEWORK_PATH on macOS, I am able to load the edfapi.

(hippocampus) roger@work29 PyHippocampus % export DYLD_FRAMEWORK_PATH=/Library/Frameworks
(hippocampus) roger@work29 PyHippocampus % ipython
Python 3.11.0 (main, Mar  1 2023, 12:33:14) [Clang 14.0.6 ]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.29.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import pyedfread

I haven't found a way to set this from within python, though.

grero avatar Jan 20 '25 04:01 grero