2

I'm working on a python project using spyder from anaconda and I am trying to get the animation function working.

I found a basic animation example here: http://matplotlib.org/1.4.1/examples/animation/basic_example.html and tried to make it work.

However when I run it, nothing happens both in the Python and iPython console.

I found this answer: Animation from matplotlib not working in spyder However, changing the preferences does not do anything and typing in %matplotlib qt returns: No module named qt4.

Spyder Version: 3.1.0 Running on MacOS Sierra

Community
  • 1
  • 1
S Singh
  • 21
  • 1
  • 3
  • Did you try running it using the option "Execute in a new dedicated python console" from the "Run Settings"? Can you run a normal matplotlib example without animation? Can you run the example from the normal system console outside spyder? How did you install matplotlib and spyder? – ImportanceOfBeingErnest Jan 23 '17 at 21:59
  • I just tried those settings now, but still I am getting nothing. Yes, normal matplotlib works without the animation. I have tried running the example outside spyder in idle, but I don't have the relevant modules. I did not specifically install matplotlib and spyder, but I downloaded anaconda navigator and launched spyder which had matplotlib preinstalled. – S Singh Jan 23 '17 at 22:11
  • If you do not have the relevant modules, you cannot run it (if idle cannot find the modules, spyder will not find them either). So I suggest installing "the relevant modules" (whatever you mean by that). – ImportanceOfBeingErnest Jan 23 '17 at 22:19
  • I mean that I can run a basic matplotlib in spyder without having to install the modules, however in python it says no module named matplotlib – S Singh Jan 23 '17 at 22:27
  • Do you have by now two python versions installed? The one from anaconda and another one? That can cause huge problems. – ImportanceOfBeingErnest Jan 23 '17 at 22:43
  • Yes I do, it is very confusing. What would you recommend doing? – S Singh Jan 23 '17 at 22:48
  • The best way would be to uninstall both of them, make sure they are completely off your computer. Then install exactly one python distribution, either anaconda or any other. – ImportanceOfBeingErnest Jan 23 '17 at 22:50

2 Answers2

1

You need to run

%matplotlib qt5

before running the animation, instead of

%matplotlib qt

because that only works for Qt4.

Carlos Cordoba
  • 33,273
  • 10
  • 95
  • 124
0

Thanks everyone for the answers. I found out my error, it was that I forgot to add .py to the file name so Spyder did not recognise them as python files.

S Singh
  • 21
  • 1
  • 3