1

I'm new to both python and OSX, so if i'm not understanding super basic stuff please forgive me.

I'm using python 2.7.12 on a fresh install from Homebrew. I also used Homebrew to install ipython, ffmpeg and libav (installs avconv, which I believe is required for what i'm trying to do).

  • I've used pip to install Scipy, numpy (which I think comes with scipy anyway?) and matplotlib
  • I'm running El Capitan v10.11.6

Background (for some context): I'm running some hydrodynamic simulations that output a bunch of binary files. I wan't to stitch them together to create a movie. Lucky for me, one of my colleagues has already written a tidy little python script to do so (which he wrote in ipython).

Problem: When trying to run

import matplotlib.animation

The script just hangs, and matplotlib animation never gets imported. I've tried changing the backend via

import matplotlib
matplotlib.use('tkagg')
import matplotlib.animaton

I've tried various backends that I got by running code from List of all available matplotlib backends

I have also tried import matplotlib.pyplot hangs (updating fc-lists)

Lastly, and i'm not sure if this is helpful, but leaving ipython trying to import matplot.animation for about 10 minutes, and then terminating it outputs the following

In [3]: import matplotlib.animation
^C---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-3-64e90e455a86> in <module>()
----> 1 import matplotlib.animation

/usr/local/lib/python2.7/site-packages/matplotlib/animation.py in <module>()
    589
    590 @writers.register('imagemagick')
--> 591 class ImageMagickWriter(MovieWriter, ImageMagickBase):
    592     def _args(self):
    593         return ([self.bin_path(),

/usr/local/lib/python2.7/site-packages/matplotlib/animation.py in wrapper(writerClass)
     73     def register(self, name):
     74         def wrapper(writerClass):
---> 75             if writerClass.isAvailable():
     76                 self.avail[name] = writerClass
     77             return writerClass

/usr/local/lib/python2.7/site-packages/matplotlib/animation.py in isAvailable(cls)
    284                              stderr=subprocess.PIPE,
    285                                      creationflags=subprocess_creation_flags)
--> 286             p.communicate()
    287             return True
    288         except OSError:

    /usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/ lib/python2.7/subprocess.pyc in communicate(self, input)
    798             return (stdout, stderr)
    799
--> 800         return self._communicate(input)
    801
    802

    /usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.pyc in _communicate(self, input)
   1417                 stdout, stderr =     self._communicate_with_poll(input)
   1418             else:
-> 1419                 stdout, stderr =     self._communicate_with_select(input)
   1420
   1421             # All data exchanged.  Translate lists into strings.

/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.pyc in _communicate_with_select(self, input)
   1518             while read_set or write_set:
   1519                 try:
-> 1520                     rlist, wlist, xlist =     select.select(read_set, write_set, [])
   1521                 except select.error, e:
   1522                     if e.args[0] == errno.EINTR:

KeyboardInterrupt:

If you give any of this a second thought, even if you aren't able to help, thank you very much!

Community
  • 1
  • 1
jgr
  • 13
  • 3
  • What commands did you use to install the plugins? Do you get the same result if you run if from a script as if you run it from the prompt? – pingul Oct 24 '16 at 22:00
  • By plugins do you mean matplotlib etc? I used pip to install those. Eg, pip install matplotlib. And yes, if I run the script via navigating to the folder and doing python script.py, it hangs on the import line just the same as it does through ipython, or if I just input it in the prompt – jgr Oct 24 '16 at 22:07
  • Are you using a virtual environment? Or did you need to do `sudo pip install ...`? Also, have you tried the normal python? I.e. not ipython. – pingul Oct 25 '16 at 07:54
  • Also, could you edit your question with the result of you doing `pip freeze`? – pingul Oct 25 '16 at 07:59

1 Answers1

0

Do you have more than one version of Python installed? I would check your python path. Make sure matplotlib is in 2.7 in this case.

This might be relevant too -- import matplotlib.pyplot hangs

Community
  • 1
  • 1
  • Thanks for your reply. I when I originally encountered this issue I also had python installed via anaconda2. I have since removed that via using the conda-clean 'thing' (https://docs.continuum.io/anaconda/install#os-x-uninstall). My python path is as follows: PYTHONPATH=~/usr/local/lib/python2.7:$PYTHONPATH – jgr Oct 24 '16 at 23:34
  • with export PYTHONPATH after that – jgr Oct 24 '16 at 23:35
  • It appears that there may have been an issue with my PATH and PYTHONPATH (the syntax I used was incorrect). – jgr Oct 25 '16 at 11:21
  • I had a similar issue with anaconda in the past. The issue is resolved then? – SchwiftyPython Oct 29 '16 at 21:35
  • Somewhat (apologies for the late reply) I have to change my PYTHON to /usr/bin/python2.7 if I want to be able to run my script with python script.py. I then have the issue that I can't use ipython (as I've installed ipython through homebrew). I haven't been able to find a more permanent fix as of yet – jgr Nov 18 '16 at 22:29