patmejia/contrails_vision

Pylance Error: Unknown Member ‘FuncAnimation’ in FuncAnimation Class

Closed this issue · 2 comments

Pylance error: ‘FuncAnimation’ member unknown in ‘FuncAnimation’ class.

Cannot access member "FuncAnimation" for type "FuncAnimation"
  Member "FuncAnimation" is unknownPylance[reportGeneralTypeIssues](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportGeneralTypeIssues)
(class) FuncAnimation
 [See Real World Examples From GitHub](vscode-file://vscode-app/Applications/Visual%20Studio%20Code%20-%20Insiders.app/Contents/Resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)

Debugging:

Checked if the FuncAnimation class can be imported by running the command:

python -c "from matplotlib.animation import FuncAnimation; print(FuncAnimation)"

Console output:

(contrail_env) ➜  contrails-vision git:(contrail-animation) ✗ python -c "from matplotlib.animation import FuncAnimation; print(FuncAnimation)"

<class 'matplotlib.animation.FuncAnimation'>

Conclusion: The FuncAnimation class was successfully imported from the matplotlib.animation module.

References:

https://stackoverflow.com/questions/62314639/trouble-with-loading-funcanimation-from-matplotlib-animation
https://stackoverflow.com/questions/70867679/can-pylance-handle-with-new-members-in-inherited-classes
microsoft/pylance-release#2198
matplotlib/matplotlib#5314
https://stackoverflow.com/questions/36546991/get-error-when-importing-funcanimation-from-matplotlib-animation
https://stackoverflow.com/questions/70867679/can-pylance-handle-with-new-members-in-inherited-classes

Solution:

Issue with accessing the FuncAnimation class from the matplotlib.animation module: one possible solution is to change how you're importing the class.

Instead of using the following import statement:

from matplotlib import animation

Try using this import statement instead:

from matplotlib.animation import FuncAnimation

This will directly import the FuncAnimation class from the matplotlib.animation module, which might resolve the issue.

Examples:

https://github.com/patmejia/contrails-vision/blob/main/src/utils/contrail_animation.py