# unable to determine if "filename.h5" is accessible in the HDF5 format (file may not exist)

**URL:** <https://itensor.discourse.group/t/unable-to-determine-if-filename-h5-is-accessible-in-the-hdf5-format-file-may-not-exist/236>\
**Category:** ITensor Julia Questions\
**Tags:** julia, mps\
**Created:** [July 5, 2022, 4:16pm UTC](https://itensor.discourse.group/t/unable-to-determine-if-filename-h5-is-accessible-in-the-hdf5-format-file-may-not-exist/236 "2022-07-05T16:16:14Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kartikeya](https://avatars.discourse-cdn.com/v4/letter/k/e9c0ed/32.png) [@Kartikeya](https://itensor.discourse.group/u/Kartikeya)\
**Post date:** [July 5, 2022, 4:16pm UTC](https://itensor.discourse.group/t/unable-to-determine-if-filename-h5-is-accessible-in-the-hdf5-format-file-may-not-exist/236/1 "2022-07-05T16:16:14Z")

</div>

I saved an MPS using `ITensors.HDF5` but while loading it, I get the error  
` unable to determine if "filename.h5" is accessible in the HDF5 format (file may not exist)` (assuming that the file is _filename.h5_).

I even ran the program in the same directory as the .h5 file itself but I keep getting the same error. The file doesn’t seem to be corrupted (it’s quite heavy, around 1.8 GB).

How do I solve this?

Best,  
Kartikeya

---

<div class="post-metadata">

**Author:** ![miles](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/miles/32/6_2.png) [@miles](https://itensor.discourse.group/u/miles)\
**Post date:** [July 5, 2022, 4:32pm UTC](https://itensor.discourse.group/t/unable-to-determine-if-filename-h5-is-accessible-in-the-hdf5-format-file-may-not-exist/236/2 "2022-07-05T16:32:04Z")

</div>

Unfortunately I don’t think we can provide very much help with this. It sounds to me like a bug or issue with the Julia HDF5 library, or the underlying C HDF5 library that Julia HDF5 wraps around. (ITensors.HDF5 is just a shorthand for the HDF5.jl Julia library which we do not maintain.)

You may make some progress searched on the Julia language Discourse forum to see if others have gotten a similar error message.

---

<div class="post-metadata">

**Author:** ![Kartikeya](https://avatars.discourse-cdn.com/v4/letter/k/e9c0ed/32.png) [@Kartikeya](https://itensor.discourse.group/u/Kartikeya)\
**Post date:** [July 7, 2022, 4:50pm UTC](https://itensor.discourse.group/t/unable-to-determine-if-filename-h5-is-accessible-in-the-hdf5-format-file-may-not-exist/236/3 "2022-07-07T16:50:17Z")

</div>

Hi Miles,

I couldn’t find any resource to solve this error. Please let me know if have anything in mind to solve this.

Is there any other way to save these MPS files to use in Julia? I mean apart from HDF5.

---

<div class="post-metadata">

**Author:** ![miles](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/miles/32/6_2.png) [@miles](https://itensor.discourse.group/u/miles)\
**Post date:** [July 7, 2022, 5:11pm UTC](https://itensor.discourse.group/t/unable-to-determine-if-filename-h5-is-accessible-in-the-hdf5-format-file-may-not-exist/236/4 "2022-07-07T17:11:13Z")

</div>

Hi Kartikeya,  
I’m really not sure why this error is happening without more information. Could you share the code you are using? Also did you get a longer printout of the error showing a “backtrace” of where the problem is occurring?

Miles

---

<div class="post-metadata">

**Author:** ![mtfishman](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/mtfishman/32/11_2.png) [@mtfishman](https://itensor.discourse.group/u/mtfishman)\
**Post date:** [July 7, 2022, 5:51pm UTC](https://itensor.discourse.group/t/unable-to-determine-if-filename-h5-is-accessible-in-the-hdf5-format-file-may-not-exist/236/5 "2022-07-07T17:51:59Z")

</div>

In the meantime while you try to resolve the error you are seeing with HDF5, you can try a package like [JLD2](https://github.com/JuliaIO/JLD2.jl) that can save and load any Julia object.

---

<div class="post-metadata">

**Author:** ![JanReimers](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/janreimers/32/171_2.png) [@JanReimers](https://itensor.discourse.group/u/JanReimers)\
**Post date:** [November 8, 2022, 10:09pm UTC](https://itensor.discourse.group/t/unable-to-determine-if-filename-h5-is-accessible-in-the-hdf5-format-file-may-not-exist/236/6 "2022-11-08T22:09:41Z")

</div>

FYI, I am seeing the same error when running the unit tests

# julia .julia/dev/ITensors/test/readwrite.jl

 ![readwrite](https://global.discourse-cdn.com/free1/uploads/itensor/original/1X/63bac82a3cf48b2197f601af859ecafab5332762.png)

HDF5 v0.16.12  
ITensors v0.3.20 `~/.julia/dev/ITensors`  
Ubuntu 22.04

Presumably the continuous integration server jenkins is not picking up this problem, or all PRs would fail, no?  
It looks like dense tensors can write, but diag/block tensors cannot !!?! (but only for some people)

---

<div class="post-metadata">

**Author:** ![ryanlevy](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/ryanlevy/32/150_2.png) [@ryanlevy](https://itensor.discourse.group/u/ryanlevy)\
**Post date:** [November 9, 2022, 2:17pm UTC](https://itensor.discourse.group/t/unable-to-determine-if-filename-h5-is-accessible-in-the-hdf5-format-file-may-not-exist/236/7 "2022-11-09T14:17:24Z")

</div>

The unit test error you’re seeing is probably because Diag tensor has an error and doesn’t close the file `data.h5`. Support for Diag ITensors [was added](https://github.com/ITensor/ITensors.jl/commit/400a7945e910465faa6047e1f1dfe467aa708052) after the latest release (v0.3.20) .

I’ve opened a [bug report](https://github.com/ITensor/ITensors.jl/issues/1005) re: the test failures

---

<div class="post-metadata">

**Author:** ![Bob](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@Bob](https://itensor.discourse.group/u/Bob)\
**Post date:** [May 1, 2023, 1:09am UTC](https://itensor.discourse.group/t/unable-to-determine-if-filename-h5-is-accessible-in-the-hdf5-format-file-may-not-exist/236/8 "2023-05-01T01:09:14Z")

</div>

I just tried to save an MPS for the first time with my own code and I am also getting this error. I am using ITensors v0.3.23. Below is some code get replicates the issue for me.

```julia
using ITensors, ITensors.HDF5

begin
    d = 2
    N = 10
    n = d^N
    x = LinRange(0, 1, n)
    y = 2 * x
    inds = siteinds(d, N)
    ȳ = MPS(y, inds)
end

h5open("mps.hdf5", "w") do fid
    create_group(fid, "mps")
    fid["mps"]["y"] = ȳ
end

h5open("mps.hdf5", "r") # error happens here

```

---

<div class="post-metadata">

**Author:** ![Bob](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@Bob](https://itensor.discourse.group/u/Bob)\
**Post date:** [May 1, 2023, 2:06am UTC](https://itensor.discourse.group/t/unable-to-determine-if-filename-h5-is-accessible-in-the-hdf5-format-file-may-not-exist/236/9 "2023-05-01T02:06:34Z")

</div>

Disregard.

I forgot that commands will use the root workspace. I was doing

```auto
h5open("mps.hdf5", "r")

```

I should have done

```auto
h5open("path/to/current/directory/mps.hdf5", "r")

```

Once I fixed the path issue it works no problem now.

Sorry for any confusion.

---

<div class="post-metadata">

**Author:** ![miles](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/miles/32/6_2.png) [@miles](https://itensor.discourse.group/u/miles)\
**Post date:** [May 1, 2023, 2:41am UTC](https://itensor.discourse.group/t/unable-to-determine-if-filename-h5-is-accessible-in-the-hdf5-format-file-may-not-exist/236/10 "2023-05-01T02:41:33Z")

</div>

Ok thanks for letting us know anyway!
