# AttributeError: module 'h5py' has no attribute 'File'

**URL:** <https://forum.hdfgroup.org/t/attributeerror-module-h5py-has-no-attribute-file/11963>\
**Category:** h5py\
**Created:** [January 29, 2024, 2:02pm UTC](https://forum.hdfgroup.org/t/attributeerror-module-h5py-has-no-attribute-file/11963 "2024-01-29T14:02:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yeyuchen](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/y/c67d28/32.png) [@yeyuchen](https://forum.hdfgroup.org/u/yeyuchen)\
**Post date:** [January 29, 2024, 2:02pm UTC](https://forum.hdfgroup.org/t/attributeerror-module-h5py-has-no-attribute-file/11963/1 "2024-01-29T14:02:27Z")

</div>

I have configured a parallel version of hdf5 on my WSL2 Ubuntu 22.04 on Windows 11 system.  
In C and Fortran, parallel hdf5 works quite well. However, things get muddy when I’m following [this guide](https://docs.h5py.org/en/stable/mpi.html#building-against-parallel-hdf5) to install parallel h5py , and trying to run the [demo code](https://docs.h5py.org/en/stable/mpi.html#using-parallel-hdf5-from-h5py). The system continues to complain _AttributeError: module ‘h5py’ has no attribute ‘File’_.

I searched for several cases on StackExchange but none of those seem to work. I installed mpi4py and h5py simply by pip3, so there is nothing to do with conda error. It’s highly appreciated if anyone can give some suggestions.

---

<div class="post-metadata">

**Author:** ![ajelenak](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/a/3d9bf3/32.png) [@ajelenak](https://forum.hdfgroup.org/u/ajelenak)\
**Post date:** [January 30, 2024, 2:20am UTC](https://forum.hdfgroup.org/t/attributeerror-module-h5py-has-no-attribute-file/11963/2 "2024-01-30T02:20:13Z")

</div>

Hi @yeyuchen,

That AttributeError usually is caused by a bad installation of h5py. Can you provide exact commands you used to install libhdf5, h5py? You mention “conda error”. Did you install the parallel version of libhdf5 via the conda package manager?

Take care,  
Aleksandar

---

<div class="post-metadata">

**Author:** ![yeyuchen](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/y/c67d28/32.png) [@yeyuchen](https://forum.hdfgroup.org/u/yeyuchen)\
**Post date:** [January 31, 2024, 12:58am UTC](https://forum.hdfgroup.org/t/attributeerror-module-h5py-has-no-attribute-file/11963/3 "2024-01-31T00:58:58Z")

</div>

Hi @ajelenak ,

Thanks for your reply. Below is the command I used for install hdf5 and h5py:

```auto
 ./configure --prefix=/usr/local --enable-parallel --enable-fortran --enable-shared
 export CC=mpicc
 export HDF5_MPI="ON"
 export HDF5_DIR="/usr/local"
 pip3 install --no-binary=h5py h5py

```

There is nothing to do with conda. This is just a solution come from [here](https://stackoverflow.com/questions/60917467/alternating-errors-using-hdf5-library-and-h5py-module) and I’m not in this case.

Regards,  
Yuchen

---

<div class="post-metadata">

**Author:** ![ajelenak](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/a/3d9bf3/32.png) [@ajelenak](https://forum.hdfgroup.org/u/ajelenak)\
**Post date:** [January 31, 2024, 3:31pm UTC](https://forum.hdfgroup.org/t/attributeerror-module-h5py-has-no-attribute-file/11963/4 "2024-01-31T15:31:08Z")

</div>

The install commands look okay. I assume the output from that `pip3` command is not available now?

One useful check would be to verify what is actually installed as h5py. You should have an `h5py` directory under the `site-packages` directory. To find out the location of the site packages directory, run this command:

```auto
python -c "import site; print(site.getsitepackages())"

```

In the `h5py` directory, there should be a `_hl` one, and in it a `files.py` file. The AttributeError you reported indicates that this file is missing in your installation.

Take care,  
Aleksandar

---

<div class="post-metadata">

**Author:** ![thomas1](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/thomas1/32/1733_2.png) [@thomas1](https://forum.hdfgroup.org/u/thomas1)\
**Post date:** [February 14, 2024, 10:38am UTC](https://forum.hdfgroup.org/t/attributeerror-module-h5py-has-no-attribute-file/11963/5 "2024-02-14T10:38:12Z")

</div>

Errors like this can often occur if you’ve got a file called `h5py.py` in the same directory where you’re running the code - `import h5py` will find this file instead of your h5py installation.
