Skip to content

Failed import -from pyhdf import SD on Google Collab #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
slobodan-ilic opened this issue Jan 9, 2023 · 1 comment
Open

Failed import -from pyhdf import SD on Google Collab #64

slobodan-ilic opened this issue Jan 9, 2023 · 1 comment

Comments

@slobodan-ilic
Copy link

What version of pyhdf, HDF4, and Python are you using?

pyhdf version: 0.10.5
HDF4 C library version: libhdf4-4.2.13
Python version: 3.8.16

What operating system are you using?

GNU/Linux (Google Collab)

What did you do?

!pip install pyhdf
from pyhdf import SD

What did you expect to see?

The import is successful

What did you see instead?

The import breaks with:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
RuntimeError: module compiled against API version 0xf but this version of numpy is 0xe
---------------------------------------------------------------------------
SystemError                               Traceback (most recent call last)
[<ipython-input-20-9e0d221b6649>](https://localhost:8080/#) in <module>
      1 get_ipython().system('pip install pyhdf')
----> 2 from pyhdf import SD

3 frames
[/usr/local/lib/python3.8/dist-packages/pyhdf/SD.py](https://localhost:8080/#) in <module>
   1001 import os, sys, types
   1002 
-> 1003 from . import hdfext as _C
   1004 from .six.moves import xrange
   1005 from .error import _checkErr, HDF4Error

[/usr/local/lib/python3.8/dist-packages/pyhdf/hdfext.py](https://localhost:8080/#) in <module>
     15         except ImportError:
     16             return importlib.import_module('_hdfext')
---> 17     _hdfext = swig_import_helper()
     18     del swig_import_helper
     19 elif _swig_python_version_info >= (2, 6, 0):

[/usr/local/lib/python3.8/dist-packages/pyhdf/hdfext.py](https://localhost:8080/#) in swig_import_helper()
     12         mname = '.'.join((pkg, '_hdfext')).lstrip('.')
     13         try:
---> 14             return importlib.import_module(mname)
     15         except ImportError:
     16             return importlib.import_module('_hdfext')

[/usr/lib/python3.8/importlib/__init__.py](https://localhost:8080/#) in import_module(name, package)
    125                 break
    126             level += 1
--> 127     return _bootstrap._gcd_import(name[level:], package, level)
    128 
    129 

SystemError: initialization of _hdfext raised unreported exception
@abrammer
Copy link
Contributor

Numpy in google colab is a couple versions out of date which causes these issues. At the top of your notebook you can add a
!pip install --upgrade numpy==1.22.4 pyhdf which seems to satisfy the rest of the environment and work for the built distribution of pyhdf. You'll have to restart the runtime though to replace the auto-imported numpy. Colab will warn about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants