Contextualversionconflict (numpy 1.19.2), requirement.parse (numpy<1.27.0,>=1.19.5), (scipy)

import strawberryfields as sf
from strawberryfields import ops

dev=qml.device(“strawberryfields.tf”, wires=4, cutoff_dim=4)

it throws an error of contextual version conflict.

I tried “strawberryfields.fock” as device, but still did not work.

I updated numpy version also. But still it throws a same error.

Hey @Amandeep,

Sounds like you just need to update numpy to something more than 1.19.2, which you can do via pip install numpy==1.23.5, for example. Does that solve the issue?

@isaacdevlugt

Thank you for your response.
I already did that. But still the error remains same.

Can you provide your full code that reproduces the error along with strawberryfields.about()?

after importing the libraries. I am just declaring the qml.device at the beginning.

from pennylane import numpy as np
import pennylane as qml
import tensorflow as tf
import strawberryfields as sf
from strawberryfields import ops

dev=qml.device(“strawberryfields.tf”, wires=4, cutoff_dim=4)

Hmm, I can’t replicate your error. Here is the output of sf.about() and qml.about() for me:

Strawberry Fields: a Python library for continuous-variable quantum circuits.
Copyright 2018-2020 Xanadu Quantum Technologies Inc.

Python version:            3.9.14
Platform info:             macOS-13.3.1-x86_64-i386-64bit
Installation path:         /Users/isaac/pennylane-sf-plugin/lib/python3.9/site-packages/strawberryfields
Strawberry Fields version: 0.23.0
Numpy version:             1.23.5
Scipy version:             1.10.1
SymPy version:             1.12
NetworkX version:          3.1
The Walrus version:        0.20.0
Blackbird version:         0.5.0
XCC version:               0.3.0
TensorFlow version:        2.12.0
Name: PennyLane
Version: 0.29.1
Summary: PennyLane is a Python quantum machine learning library by Xanadu Inc.
Home-page: https://github.com/XanaduAI/pennylane
Author: 
Author-email: 
License: Apache License 2.0
Location: /Users/isaac/pennylane-sf-plugin/lib/python3.9/site-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, requests, retworkx, scipy, semantic-version, toml
Required-by: PennyLane-Lightning, PennyLane-SF

Platform info:           macOS-13.3.1-x86_64-i386-64bit
Python version:          3.9.14
Numpy version:           1.23.5
Scipy version:           1.10.1
Installed devices:
- default.gaussian (PennyLane-0.29.1)
- default.mixed (PennyLane-0.29.1)
- default.qubit (PennyLane-0.29.1)
- default.qubit.autograd (PennyLane-0.29.1)
- default.qubit.jax (PennyLane-0.29.1)
- default.qubit.tf (PennyLane-0.29.1)
- default.qubit.torch (PennyLane-0.29.1)
- default.qutrit (PennyLane-0.29.1)
- null.qubit (PennyLane-0.29.1)
- strawberryfields.fock (PennyLane-SF-0.29.1)
- strawberryfields.gaussian (PennyLane-SF-0.29.1)
- strawberryfields.gbs (PennyLane-SF-0.29.1)
- strawberryfields.remote (PennyLane-SF-0.29.1)
- strawberryfields.tf (PennyLane-SF-0.29.1)
- lightning.qubit (PennyLane-Lightning-0.30.0)

Note that the PL-SF is only supported up to v0.29.1 of PennyLane :slight_smile:

@isaacdevlugt
I did that.

Strawberry Fields: a Python library for continuous-variable quantum circuits.
Copyright 2018-2020 Xanadu Quantum Technologies Inc.

Python version: 3.8.16
Platform info: Linux-3.10.0-1160.62.1.el7.x86_64-x86_64-with-glibc2.17
Installation path: /home/bhatia87/.conda/envs/cent7/2020.11-py38/abcd/lib/python3.8/site-packages/strawberryfields
Strawberry Fields version: 0.23.0
Numpy version: 1.23.5
Scipy version: 1.10.1
SymPy version: 1.8
NetworkX version: 2.8.4
The Walrus version: 0.20.0
Blackbird version: 0.5.0
XCC version: 0.3.0

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: /home/bhatia87/.local/lib/python3.8/site-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, requests, retworkx, scipy, semantic-version, toml
Required-by: PennyLane-Lightning, PennyLane-qiskit, PennyLane-SF, pennylearn

Platform info: Linux-3.10.0-1160.62.1.el7.x86_64-x86_64-with-glibc2.17
Python version: 3.8.16
Numpy version: 1.23.5
Scipy version: 1.10.1
Installed devices:

  • default.gaussian (PennyLane-0.28.0)
  • default.mixed (PennyLane-0.28.0)
  • default.qubit (PennyLane-0.28.0)
  • default.qubit.autograd (PennyLane-0.28.0)
  • default.qubit.jax (PennyLane-0.28.0)
  • default.qubit.tf (PennyLane-0.28.0)
  • default.qubit.torch (PennyLane-0.28.0)
  • default.qutrit (PennyLane-0.28.0)
  • null.qubit (PennyLane-0.28.0)
  • lightning.qubit (PennyLane-Lightning-0.29.0)
  • strawberryfields.fock (PennyLane-SF-0.29.1)
  • strawberryfields.gaussian (PennyLane-SF-0.29.1)
  • strawberryfields.gbs (PennyLane-SF-0.29.1)
  • strawberryfields.remote (PennyLane-SF-0.29.1)
  • strawberryfields.tf (PennyLane-SF-0.29.1)
  • qiskit.aer (PennyLane-qiskit-0.29.0)
  • qiskit.basicaer (PennyLane-qiskit-0.29.0)
  • qiskit.ibmq (PennyLane-qiskit-0.29.0)
  • qiskit.ibmq.circuit_runner (PennyLane-qiskit-0.29.0)
  • qiskit.ibmq.sampler (PennyLane-qiskit-0.29.0)

I tried creating a virtual environment with those exact specs and I can’t replicate your version issue :thinking:. Maybe a safe bet to delete this virtual environment and then python -m pip install pennylane pennylane-sf strawberryfields. Let me know if that works! Sometimes virtual environments get messy and need deleting.