Page 1 of 1

Colab Import Error

Posted: Wed Apr 10, 2024 12:17 pm
by david6464_
Hello, I'm getting an error importing packages in colab. I'm trying to run a kinematics analysis through the colab scripts. I get this error: ImportError Traceback (most recent call last)
<ipython-input-2-297b6a014f0a> in <cell line: 6>()
4 import numpy as np
5 import matplotlib.pyplot as plt
----> 6 import utilsKinematics
7 from utils import download_kinematics

1 frames
/content/opencap-processing/utils.py in <module>
35 from utilsAuthentication import get_token
36 import matplotlib.pyplot as plt
---> 37 from scipy.signal import gaussian
38
39

ImportError: cannot import name 'gaussian' from 'scipy.signal' (/usr/local/lib/python3.10/site-packages/scipy/signal/__init__.py)

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------

Any help is appreciated, thank you!

Re: Colab Import Error

Posted: Fri Apr 19, 2024 11:27 am
by antoinefalisse
There was a bug in the latest version of scipy. I fixed the scipy version and it should work now. Let us know otherwise.

Re: Colab Import Error

Posted: Mon Nov 18, 2024 12:58 pm
by samner
FYI

@Antoine I was running into a similar issue recently setting up a new computer to perform the Example.py following the readme on opencap-processing github, but I was having an issue with SciPy importing the gaussian function. Here is the error:
(opencap-processing) C:\Users\samner\OneDrive\Documents\samnerScripts\opencap-processing\opencap-processing>python example.py
Traceback (most recent call last):
File "C:\Users\samner\OneDrive\Documents\samnerScripts\opencap-processing\opencap-processing\example.py", line 22, in <module>
import utilsKinematics
File "C:\Users\samner\OneDrive\Documents\samnerScripts\opencap-processing\opencap-processing\utilsKinematics.py", line 23, in <module>
import utils
File "C:\Users\samner\OneDrive\Documents\samnerScripts\opencap-processing\opencap-processing\utils.py", line 37, in <module>
from scipy.signal import gaussian
ImportError: cannot import name 'gaussian' from 'scipy.signal' (C:\Users\samner\.conda\envs\opencap-processing\Lib\site-packages\scipy\signal\__init__.py)
I read online that there is an issue with SciPy 1.14 and ArViz, and downgrading to SciPy<1.13 would resolve the issue until a new version of SciPy is released (ArViz was to blame, apparently). I downgraded to 1.12 using the code below, and voila, it worked!

Code: Select all

pip install scipy==1.12
Here's the link to the blog re: SciPy and ArViz https://discourse.pymc.io/t/importerror ... gnal/14170

Re: Colab Import Error

Posted: Mon Nov 18, 2024 6:04 pm
by ongcf
There was a recent PR that updated this import: https://github.com/stanfordnmbl/opencap ... /132/files

The issue was that the import was deprecated and finally removed from SciPy, so we updated the import line in utils.py for the import. It should now work on current versions of SciPy (more info can be found in the related GitHub issue: https://github.com/stanfordnmbl/opencap ... issues/131).

Sam, since this was very recently merged (3 days ago), you'd have to pull the latest commit for opencap-processing to see if this would help your use case and avoid needing to downgrade SciPy.