Module 'pennylane' has no attribute 'Fockstate'

Hello, I am currently going through the tutorial on Plugins and Hybrid Computation at (https://)[Plugins and hybrid computation — PennyLane documentation].

When I run the following code:
def cost(params):
return -photon_redirection(params)

init_params = np.array([0.01, 0.01], requires_grad=True)
print(cost(init_params))

I receive the following:
AttributeError: Module pennylane has no attribute Fockstate

How can this issue be resolved? Thank you in advance!

Hi @gopalm-ai,

Welcome to the Forum!

Have you installed the pennylane-sf plugin? I suspect this might be the issue. You can install it by running python -m pip install pennylane-sf

If this is not the issue then it may be that you have an old version of PennyLane or Python.

Usually having the latest Python and PennyLane versions is best. Using Python 3.8-3.11 and PennyLane 0.28 should work for you. I would recommend that you follow these steps. Note that where it says “name_of_your_environment" you can choose any name that you want:

Create a new conda environment with:conda create --name name_of_your_environment python=3.11
Activate the environment:conda activate name_of_your_environment

After this you can install the needed packages:python -m pip install pennylane pennylane-sf

Please let me know if this works for you! If this doesn’t solve your issue please post the output of qml.about() and your full error traceback.

I have tried reinstalling both the pennylane-sf plugin and Python but the problem still persists.

Here is my qml.about():

Name: PennyLane
Version: 0.28.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.
Author:
Author-email:
License: Apache License 2.0
Location: /usr/local/lib/python3.8/dist-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, requests, retworkx, scipy, semantic-version, toml
Required-by: PennyLane-Lightning, PennyLane-SF

Platform info: Linux-5.10.147±x86_64-with-glibc2.29
Python version: 3.8.10
Numpy version: 1.21.6
Scipy version: 1.7.3
Installed devices:

Hi @gopalm-ai,

It seems that your message must have been cut because normally you would have information about the different devices and plugins under “Installed devices”. Is it possible that maybe you didn’t copy all of the information? Or do you get no information at all under “Installed devices”?