No attribute 'MolecularData'

I am trying to follow the tutorial https://pennylane.ai/qml/demos/tutorial_vqe.html .

import numpy as np
symbols = [“H”, “H”]
coordinates = np.array([0.0, 0.0, -0.6614, 0.0, 0.0, 0.6614])

import pennylane as qml

H, qubits = qml.qchem.molecular_hamiltonian(symbols, coordinates) print("Number of qubits = ", qubits)
print("The Hamiltonian is ", H)

But I got this output:
AttributeError: module ‘pennylane_qchem.qchem.openfermion’ has no attribute ‘MolecularData’.

Thanks!

Hi @kennethlee897 and welcome to the forum!

This seems like an installation issue. Could you please make sure that you have installed all the requirements listed here by re-installing qchem with pip install pennylane-qchem? If the error still remains, could you please run the following two commands separately and copy the outputs here?

  1. qml.about()

  2. pip show openfermion

Thanks.

The error still remains. For 1. it shows:

Name: PennyLane
Version: 0.16.0
Summary: PennyLane is a Python quantum machine learning library by Xanadu Inc.
Home-page: https://github.com/XanaduAI/pennylane
Author: None
Author-email: None
License: Apache License 2.0
Location: /Users/kennethlee897/anaconda3/lib/python3.6/site-packages
Requires: semantic-version, appdirs, toml, scipy, numpy, autoray, networkx, autograd
Required-by: PennyLane-SF, PennyLane-Qchem
Platform info: Darwin-20.4.0-x86_64-i386-64bit
Python version: 3.6.4
Numpy version: 1.19.5
Scipy version: 1.5.4
Installed devices:

  • default.gaussian (PennyLane-0.16.0)
  • default.mixed (PennyLane-0.16.0)
  • default.qubit (PennyLane-0.16.0)
  • default.qubit.autograd (PennyLane-0.16.0)
  • default.qubit.jax (PennyLane-0.16.0)
  • default.qubit.tf (PennyLane-0.16.0)
  • default.tensor (PennyLane-0.16.0)
  • default.tensor.tf (PennyLane-0.16.0)
  • strawberryfields.fock (PennyLane-SF-0.16.0)
  • strawberryfields.gaussian (PennyLane-SF-0.16.0)
  • strawberryfields.gbs (PennyLane-SF-0.16.0)
  • strawberryfields.remote (PennyLane-SF-0.16.0)
  • strawberryfields.tf (PennyLane-SF-0.16.0)

For 2., it show:

and 2.

Name: openfermion

Version: 1.0.1

Summary: The electronic structure package for quantum computers.

Home-page: http://www.openfermion.org

Author: The OpenFermion Developers

Author-email: help@openfermion.org

License: Apache 2

Location: /Users/kennethlee897/anaconda3/lib/python3.6/site-packages

Requires: h5py, deprecation, cirq, numpy, sympy, pubchempy, nbformat, scipy, requests, networkx

Required-by: PennyLane-Qchem, openfermionpyscf, openfermionpsi4

Hi @kennethlee897 and thanks for the info. Please note that PennyLane requires Python version 3.7 and above while your Python version is 3.6.4. I recommend installing a higher version of python and then reinstalling both PennyLane and PennyLane-Qchem. That should fix the issue but please let me know if you face any problems. Thanks.