AttributeError: 'HTTPFile' object has no attribute 'flush'

Hi! I’m trying to download the LiH dataset, but encounter the AttributeError below. Could you please help me figure out the solution?

Here is the code I’m running:

import pennylane as qml
from pennylane import numpy as np"qchem", molname="LiH", bondlength=1.57, basis="STO-3G")

And here is the error message:

AttributeError                            Traceback (most recent call last)
<ipython-input-2-c0a04eb26b9a> in <module>
      1 import pennylane as qml
      2 from pennylane import numpy as np
----> 3"qchem", molname="LiH", bondlength=1.57, basis="STO-3G")

C:\ProgramData\Anaconda3\lib\site-packages\pennylane\data\data_manager\ in load(data_name, attributes, folder_path, force, num_threads, block_size, **params)
    277         for result in results.done:
    278             if result.exception() is not None:
--> 279                 raise result.exception()
    281     return [, "a") for dest_path in dest_paths]

C:\ProgramData\Anaconda3\lib\concurrent\futures\ in run(self)
     56         try:
---> 57             result = self.fn(*self.args, **self.kwargs)
     58         except BaseException as exc:
     59             self.future.set_exception(exc)

C:\ProgramData\Anaconda3\lib\site-packages\pennylane\data\data_manager\ in _download_dataset(data_path, dest, attributes, block_size, force)
    131     if attributes is not None or dest.exists():
--> 132         _download_partial(
    133             s3_url, dest=dest, attributes=attributes, overwrite=force, block_size=block_size
    134         )

C:\ProgramData\Anaconda3\lib\site-packages\pennylane\data\data_manager\ in _download_partial(s3_url, dest, attributes, overwrite, block_size)
     94     if remote_dataset:
---> 95         remote_dataset.close()
     97     dest_dataset.close()

C:\ProgramData\Anaconda3\lib\site-packages\pennylane\data\base\ in close(self)
    238         """Close the underlying dataset file. The dataset will
    239         become inaccessible."""
--> 240         self.bind.close()
    242     @property

C:\ProgramData\Anaconda3\lib\site-packages\h5py\_hl\ in close(self)
    441                 for id_ in file_list:
    442                     while id_.valid:
--> 443                         h5i.dec_ref(id_)

h5py\_objects.pyx in h5py._objects.with_phil.wrapper()

h5py\_objects.pyx in h5py._objects.with_phil.wrapper()

h5py\h5i.pyx in h5py.h5i.dec_ref()

h5py\defs.pyx in h5py.defs.H5Idec_ref()

h5py\h5fd.pyx in h5py.h5fd.H5FD_fileobj_write()

h5py\h5fd.pyx in h5py.h5fd.H5FD_fileobj_truncate()

h5py\h5fd.pyx in h5py.h5fd.H5FD_fileobj_flush()

AttributeError: 'HTTPFile' object has no attribute 'flush'

Here is my qml.about() information:

Name: PennyLane
Version: 0.33.0
Summary: PennyLane is a Python quantum machine learning library by Xanadu Inc.
Home-page: GitHub - PennyLaneAI/pennylane: PennyLane is a cross-platform Python library for differentiable programming of quantum computers. Train a quantum computer the same way as a neural network.
License: Apache License 2.0
Location: c:\programdata\anaconda3\lib\site-packages
Requires: requests, cachetools, numpy, semantic-version, autoray, typing-extensions, toml, appdirs, rustworkx, scipy, networkx, pennylane-lightning, autograd
Required-by: PennyLane-Lightning

Platform info: Windows-10-10.0.19041-SP0
Python version: 3.8.5
Numpy version: 1.23.4
Scipy version: 1.8.1
Installed devices:

  • default.gaussian (PennyLane-0.33.0)
  • default.mixed (PennyLane-0.33.0)
  • default.qubit (PennyLane-0.33.0)
  • default.qubit.autograd (PennyLane-0.33.0)
  • default.qubit.jax (PennyLane-0.33.0)
  • default.qubit.legacy (PennyLane-0.33.0)
  • (PennyLane-0.33.0)
  • default.qubit.torch (PennyLane-0.33.0)
  • default.qutrit (PennyLane-0.33.0)
  • null.qubit (PennyLane-0.33.0)
  • lightning.qubit (PennyLane-Lightning-0.33.1)

Hi @juhohoo,
The latest version of PennyLane only supports Python 3.9 or higher. Please let us know if you still have this issue after updating you Python version!

I hope this solves the problem

1 Like

Hi, thank you for the reply. I’m running Python 3.10.5. Could you share more tips how to solve the error?

Hey @juhohoo, your qml.about() output says that you’re using 3.8.5:

Platform info: Windows-10-10.0.19041-SP0
Python version: 3.8.5
Numpy version: 1.23.4
Scipy version: 1.8.1
Installed devices:

Likely all you need to do is create a new virtual environment like so:

>>> python3.10 -m venv <path to virtual environment>

Then when you go to activate that environment, python 3.10 will be used :slight_smile:. Let me know if that helps!

1 Like

Good catch! Thanks a lot Isaac! :blush:

1 Like

My pleasure! Glad this helped :slight_smile: