Cannot import strawberryfields module

Hello!
When trying to import strawberryfields module, I have the following error

import strawberryfields as sf
# ImportError: cannot import name 'simps' from 'scipy.integrate' (/my_path/conda/envs/strawberry.0.23/lib/python3.12/site-packages/scipy/integrate/__init__.py). Did you mean: 'simpson'?

I have installed strawberryfields package inside an empty conda environment. After the installation, the versions of the required packages seem to be correct, according to Development guide — Strawberry Fields 0.23.0 documentation

python                    3.12.4
numpy                     2.0.1
scipy                     1.14.0
networkx                  3.3
thewalrus                 0.21.0
toml                      0.10.2

This scipy version contains simpson function instead os simps. It seems that a downgrade of scipy is needed.

Hi @jdviqueira , welcome to the Forum!

It does look like some package version issue.

I’d recommend installing Strawberry Fields in a new environment or using Google Colab.
In Colab you simply run !pip install strawberryfields
Then you can run import strawberryfields as sf

If you want to check the versions of the different packages you can run sf.about(). I ran it now and this is what I got

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

Python version:            3.10.12
Platform info:             Linux-6.1.85+-x86_64-with-glibc2.35
Installation path:         /usr/local/lib/python3.10/dist-packages/strawberryfields
Strawberry Fields version: 0.23.0
Numpy version:             1.26.4
Scipy version:             1.13.1
SymPy version:             1.13.1
NetworkX version:          3.3
The Walrus version:        0.21.0
Blackbird version:         0.5.0
XCC version:               0.3.2
TensorFlow version:        2.15.0

I hope this helps!

The issue occurres when installing in an empty environment and no package versions are specified. By specifying the versions you mention, it works.

Thank you!

1 Like