Skip to content
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

AttributeError: h5py.h5.H5PYConfig' has no attribute '__reduce_cython__' #1477

Closed
prpeixoto opened this issue Jan 22, 2020 · 19 comments
Closed

Comments

@prpeixoto
Copy link

Hello all,

  • Operating System Windows 10
  • Python version 3.7
  • Windows
  • h5py version 2.10
  • tensorflow version 2.0.0

I'm trying to load a previously saved tensorflow model that was saved using th5 extension on my program, however, when trying to import the tensorflow library, the error bellow is displayed. I've tried downgrading the h5py, and it didn't work. I also tried the newer version of tensorflow with no result. Does anyone have any idea what could be causing this? Thank you

The error displayed:
AttributeError("type object 'h5py.h5.H5PYConfig' has no attribute 'reduce_cython'")

@michaelStettler
Copy link

michaelStettler commented Mar 2, 2020

So I am also having this issue and apparently one workaround would be to downgrade to 2.7. I also tried 2.8 and 2.9 and the issue remained. But in my case when trying the 2.7 I got the following:

C:\Users\Michael\AppData\Local\Temp\pip-install-wxsonm08\h5py\h5py\api_compat.h(27): fatal error C1083: Cannot open include file: 'hdf5.h': No such file or directory
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\bin\HostX86\x64\cl.exe' failed with exit status 2

@tacaswell
Copy link
Member

@prpeixoto That looks like an installation issue. I suggest uninstalling and reinstalling h5py via which ever mechanism you are using

@michaelStettler That looks like you are trying to compile h5py from source but do not have the hdf5 headers available on your system.

@michaelStettler
Copy link

Thanks for your answer. May I ask if you could point me out to get the headers correctly ?
Actually by continuing trying, I also realised that installing the 2.7 works perfectly fine with python 3.6

@tacaswell
Copy link
Member

I suggest looking at the appveyor config files (https://github.com/h5py/h5py/blob/master/appveyor.yml) which show how we build h5py on windows for CI.

I am unfortunately not really qualified to answers how to get headers on windows beyond that.

@michaelStettler
Copy link

Thanks! I'll have a look
Quick update so far, it seems that downgrading to python 3.6 and h5py 2.7 does the trick for me. But I have to say it also feels like h5py may be involved in that issue since I got again the problem (which appears also a couple of times on stack overflow) when using again h5py 2.10 and python 3.6.
It would be nice to know if something changed between 2.7 and 2.8, especially as in the commit for 2.8 it says: - Minimum version of cython is now 0.23.

But so far at least I have no more error messages with:
python 3.6
tensorflow-gpu 2.1
h5py 2.7

I'll continue and edit my message if it all works fine for me.

@tacaswell
Copy link
Member

I do not doubt that the built binary artifacts from h5py are involved, but I think the root of the issue is a miss-match between the other libraries. This should be reported to who ever is providing your packages and possibly to the tensorflow folks.

I do not think there is anything we can do about this on the code side in h5py.

@michaelStettler
Copy link

I see, well thanks anyway

From my side, I confirm that my project runs with h5py 2.7.

@takluyver
Copy link
Member

Can anyone reproduce this error without Tensorflow?

@8Yury8
Copy link

8Yury8 commented Aug 4, 2020

Hi! I've got the same problem with Tensorflow 2.3.0.: ERROR: tensorflow 2.3.0 has requirement h5py<2.11.0,>=2.10.0, but you'll have h5py 2.7.0 which is incompatible. But I can't install it. Are there any channels to update it for Conda environment?

@ruczmz
Copy link

ruczmz commented Oct 29, 2020

Open python or jupyter, spyder with administrator rights

@takluyver
Copy link
Member

Running Python as admin is unlikely to solve a problem like this in general, even if it happened to work in one specific case. It's also bad advice in general: code running as admin has more power to mess up your system.

@princyok
Copy link

Run pip uninstall h5py multiple times to remove multiple installations (this is in conda environment).

Then run conda install -c anaconda h5py.

That fixed it for me.

@tacaswell
Copy link
Member

Closing this issue as it is an installation issue and not anything we can fix at the source level.

@bernie6401
Copy link

thanks @princyok for useful helping
indeed you can not use pip install the h5py, you have to use conda install instead

@shafaattahir
Copy link

I got the same issue, just you need to uninstall and then install it 'h5py'.

@tashrifbillah
Copy link

pip uninstall h5py
pip install h5py

worked for me. By the way, you may have to open your PowerShell with administrative privilege.

For the update to load in jupyter-notebook, I had to Ctrl+C the kernel and restart. This is surprising because I did not have to do this for other pip installed libraries as they were automatically available after installation.

@takluyver
Copy link
Member

If you upgrade something that you have already imported, it's normal that you have to restart Python (restart the kernel, in Jupyter) to pick it up.

@furkanozbilgin
Copy link

Run pip uninstall h5py multiple times to remove multiple installations (this is in conda environment).

Then run conda install -c anaconda h5py.

That fixed it for me.

Correct Solution

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

No branches or pull requests

12 participants