Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name 'simps' from 'scipy.integrate' #750

Open
1 task done
wangqiuoe opened this issue Jul 17, 2024 · 6 comments
Open
1 task done

ImportError: cannot import name 'simps' from 'scipy.integrate' #750

wangqiuoe opened this issue Jul 17, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@wangqiuoe
Copy link

Before posting a bug report

  • I have searched exisisting GitHub issues to make sure the issue does not already exist.

Expected behavior

import pacakage successfully

Actual behavior

After installation, when doing
from strawberryfields.apps import points, plot,
it reports the import error.

I've checked scipy.integrate, and the current version has simpson instead of simps method

Reproduces how often

100%

System information

File /[python enviroment]/strawberryfields/apps/__init__.py:36
     [34](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/py312/lib/python3.12/site-packages/strawberryfields/apps/__init__.py:34) import strawberryfields.apps.plot
     [35](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/py312/lib/python3.12/site-packages/strawberryfields/apps/__init__.py:35) import strawberryfields.apps.points
...
---> [27](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/py312/lib/python3.12/site-packages/strawberryfields/backends/states.py:27) from scipy.integrate import simps
     [29](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/py312/lib/python3.12/site-packages/strawberryfields/backends/states.py:29) from thewalrus.symplectic import rotation as _R
     [30](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/py312/lib/python3.12/site-packages/strawberryfields/backends/states.py:30) from thewalrus.symplectic import xpxp_to_xxpp

ImportError: cannot import name 'simps' from 'scipy.integrate'

Source code

No response

Tracebacks

No response

Additional information

No response

@wangqiuoe wangqiuoe added the bug Something isn't working label Jul 17, 2024
@CatalinaAlbornoz
Copy link

Hi @wangqiuoe ,

Thank you for opening this issue. I'm not being able to replicate your problem. It looks to me like an installation issue.

I recommended that you create a new virtual environment to avoid any installation issues. You can create a virtual environment with Conda and install Strawberry Fields as follows:

  1. Install Miniconda following the instructions here.
  2. Open your terminal (mac) or command line (Windows).
  3. Create a new Conda environment with: conda create --name <name_of_your_environment> python=3.10
  4. Activate the environment with: conda activate <name_of_your_environment>
  5. Install Strawberry Fields with: python -m pip install strawberryfields
  6. Install other useful packages with: python -m pip install jupyter matplotlib

Note that you will be installing 3 packages here: Strawberry Fields, Jupyter, and Matplotlib. Also, note that where it says <name_of_your_environment> you can choose any name that you want.

If you're still having trouble in your newly created environment please post here the output of sf.about()

import strawberryfields as sf
sf.about()

Please let us know if this resolves your issue!

@umar1kfarooq-king
Copy link

umar1kfarooq-king commented Aug 20, 2024

Hi @CatalinaAlbornoz

I have followed your method and it still ends at the same point as before

Traceback (most recent call last):

File "/home/qcl/Downloads/strawberryfields-master/examples/gate_teleportation.py", line 2, in <module>
import strawberryfields as sf

File "/home/qcl/anaconda3/envs/sf/lib/python3.10/site-packages/strawberryfields/__init__.py", line 24, in <module>
from . import apps

File "/home/qcl/anaconda3/envs/sf/lib/python3.10/site-packages/strawberryfields/apps/__init__.py", line 36, in <module>
import strawberryfields.apps.qchem

File/home/1/anaconda3/envs/sf/lib/python3.10/site-packages/strawberryfields/apps/qchem/__init__.py", line 34, in <module> 
import strawberryfields.apps.qchem.dynamics

File/home/qcl/anaconda3/envs/sf/lib/python3.10/site-packages/strawberryfields/apps/qchem/dynamics.py", line 73, in <module>
import strawberryfields.utills import operation

File "/home/qcl/anaconda3/envs/sf/lib/python3.10/site-packages/strawberryfields/utils/__init__.py", line 21, in <module>
from .program_funstions import *

from import File/hone/qcl/anaconda3/envs/sf/lib/python3.18/site-packages/strawberryfields/utils/program_functions.py", line 28, in <module> 
fron strawberryfields.engine import LocalEngine

File "/home/qcl/anaconda3/envs/sf/lib/python3.18/site-packages/strawberryfields/engine.py", line 29, in <module>
from strawberryfields.device import Device

File "/home/qcl/anaconda3/envs/sf/lib/python3.10/site-packages/strawberryfields/device.py", line 23, in <module>
from strawberryfields.io import to_program

File "/home/qcl/anaconda3/envs/sf/lib/python3.10/site-packages/strawberryfields/io/__init.py__", line 26, in <module>
from strawberryfields.program import Program

File " /home/qcl/anaconda3/envs/sf/lib/python3.18/site-packages/strawberryfields/program.py", line 62, in <module>

from strawberryfields.compilers import Compiler, compiler_db

File "/hone/ /qcl/ /anaconda3/envs/sf/lib/python3.10/site-packages/strawberryfields/compilers/__init__.py", line 40, in <module>
from .xcov import Xcov

File "/home/qcl/anaconda3/envs/sf/lib/python3.10/site-packages/strawberryftelds/comptlers/xcov.py", line 25, in <module>
import strawberryfields.ops as ops

File "/home/qcl/anaconda3/envs/sf/lib/python3.10/site-packages/strawberryfields/ops.py", line 33, in <module>
from .backends.states import BaseFockState, BaseGaussianState, BaseBosonicState

File "/home/qcl/anaconda3/envs/sf/lib/python3.10/site-packages/strawberryfields/backends/__init__.py", line 72, in <module>
from .gaussianbackend import GaussianBackend

File "/home/qcl/anaconda3/envs/sf/11b/python3.10/site-packages/strawberryflelds/backends/gausstanbackend/__init__.py", line 16, in <module>
from .backend import GaussianBackend

"/home/qcl/anaconda3/envs/sf/lib/python3.10/site-packages/strawberryflelds/backends/gausstanbackend/backend.py", line 23, in <module>
from strawberryfields.backends.states import BaseGaussianState 

File "/home/qcl/anaconda3/envs/sf/lib/python3.10/site-packages/strawberryfields/backends/states.py", line 27, in <module>
from scipy.integrate import simps

ImportError: cannot import name 'simps' from 'scipy.integrate' (/home/qcl/.local/lib/python3.10/site-packages/scipy/integrate/init_.py)

I have python==3.10

@CatalinaAlbornoz
Copy link

Hi @umar1kfarooq-king ,

You can try using Google Colab. This would be the recommended option.

If you need to install locally:
If the local Conda instructions don't work you can try creating the virtual environment with venv.
The document attached shows the instructions on how to create the virtual environment and install PennyLane. In this case instead of installing PennyLane you can install Strawberry Fields.
PennyLane installation instructions 2024.pdf

I hope this helps.

@ZiadHatab
Copy link

@CatalinaAlbornoz

I just installed strawberryfields and facing same issue with import.

I'm using Python 3.10
image

I checked scipy, they don't have a function scipy.integrate.simps (at least not anymore). The function called scipy.integrate.simpson:
https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.simpson.html

@ZiadHatab
Copy link

OK. scipy deprecated simps
scipy/scipy#21070

@CatalinaAlbornoz
Copy link

Hi @ZiadHatab,
Thank you for confirming the deprecation of simps. I'll see what we can do on our end. In the meantime please install a version of SciPy older than 1.14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants