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

Import Error: randn from scripy #412

Open
NicholasSnyder opened this issue Jan 21, 2024 · 7 comments · May be fixed by #413
Open

Import Error: randn from scripy #412

NicholasSnyder opened this issue Jan 21, 2024 · 7 comments · May be fixed by #413

Comments

@NicholasSnyder
Copy link

Describe the bug
ImportError: cannot import name 'randn' from 'scipy'

Version information
installed from pip 23.2.1

To Reproduce
Steps to reproduce the behavior:

from spatialmath.base import *
from roboticstoolbox import *

OUTPUT:
Exception has occurred: ImportError
cannot import name 'randn' from 'scipy' (C:\Users\Nicholas Snyder\AppData\Local\Programs\Python\Python312\Lib\site-packages\scipy_init_.py)
File "C:\Users\Nicholas Snyder\Downloads\RVC3-python-main\test.py", line 2, in
from roboticstoolbox import *
ImportError: cannot import name 'randn' from 'scipy' (C:\Users\Nicholas Snyder\AppData\Local\Programs\Python\Python312\Lib\site-packages\scipy_init_.py)

Expected behavior
Expected toolbox to successfully import.

Screenshots
image

Environment

  • Windows Version 10.0.19045 Build 19045
  • Python 3.12.1 64bit

Additional context
The only thing I was able to find on this issue is that scipy does not have a random module to import anymore. A proposed alternative is to use random from numpy. However, I am not sure if this is the actual underlying issue.

@kingjin94
Copy link

Can confirm this error on Python 3.9/10/11 in the official Python containers (https://hub.docker.com/_/python). "pip install scipy<1.12.0" seems to be a viable hot fix.

@FelipeCybis FelipeCybis linked a pull request Jan 22, 2024 that will close this issue
@FelipeCybis
Copy link

It turns out the scipy.randn function was not even used by robotics-toolbox-python. I created a PR to fix this.

@WendaXu2023
Copy link

I meet the same problem. Is it fixed?

@wanglong06
Copy link

I am currently having the same problem, and currently, I confirm that @kingjin94 's proposed hot fix (scipy<1.12.0) work. But a proper fix would be greatly appreciated!

@JakobDomislovic
Copy link

Go to roboticstoolbox/mobile/EKF.py and change that randn is imported from numpy and remove it from scipy import. Use: from numpy.random import randn

@daironxuan
Copy link

site-packages/roboticstoolbox/mobile/EKF.py:

from collections import namedtuple
import numpy as np
from math import pi
from scipy import integrate
from scipy.linalg import sqrtm, block_diag
from scipy.stats.distributions import chi2
import matplotlib.pyplot as plt
from matplotlib import animation

from spatialmath.base.animate import Animate
from spatialmath import base, SE2
from roboticstoolbox.mobile import VehicleBase
from roboticstoolbox.mobile.landmarkmap import LandmarkMap
from roboticstoolbox.mobile.sensors import SensorBase

# Use numpy's randn instead of scipy's
from numpy.random import randn

@pappuyadav
Copy link

I meet the same problem. Is it fixed?

#436

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants