Netpyne on clusters

A Python package that facilitates development and use of models of biological neural networks

Moderator: tom_morse

Post Reply
bremen
Posts: 45
Joined: Mon Apr 24, 2017 8:15 am
Location: Italy

Netpyne on clusters

Post by bremen »

Hi

I've been using, for last two months, a Julich cluster, based on "knight landing" (Xeon Phi) CPUs, in which i have created a virtual env, to contain all pythons modules and a locally compiled NEURON installation, as a Python module too.

Doing "from netpyne import specs, sim" generates and import error for tkinter.

Code: Select all

ImportError: No module named _tkinter. 
This is caused by matplotlib.

Code: Select all

 File "/lib/python2.7/site-packages/netpyne/sim.py", line 20, in <module>
    from . import analysis
  File "/lib/python2.7/site-packages/netpyne/analysis.py", line 12, in <module>
    import matplotlib.pyplot as plt
  File "/lib/python2.7/site-packages/matplotlib/pyplot.py", line 113, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/lib/python2.7/site-packages/matplotlib/backends/__init__.py", line 60, in pylab_setup
    [backend_name], 0)
  File "/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 6, in <module>
    from six.moves import tkinter as Tk
Is there an option to shutdown any matplotlib related activity when no GUI is available?

I'm using an ssh with no "X11 forwarding" option or other GUI related mechanisms.

Best regards
Stefano
salvadord
Posts: 86
Joined: Tue Aug 18, 2015 3:49 pm

Re: Netpyne on clusters

Post by salvadord »

Seems like there is some issue with matplotlib -- can you import it by itself outside of netpyne?

You can use the command line option '-nogui' (this sets netpyne.__gui__ to False) to avoid importing graphic-related modules -- but you won't be able to use the most analysis functions.
bremen
Posts: 45
Joined: Mon Apr 24, 2017 8:15 am
Location: Italy

Re: Netpyne on clusters

Post by bremen »

Seems like there is some issue with matplotlib -- can you import it by itself outside of netpyne?

Code: Select all

-bash-4.2$ python 
Python 2.7.12 (default, Aug  8 2016, 09:48:40) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>>  
This is the problematic import.

Code: Select all

>>> import matplotlib.pyplot as plt
/cm/shared/global/opt/Python-2.7.12/lib/python2.7/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
  warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/cm/shared/global/opt/Python-2.7.12/lib/python2.7/site-packages/matplotlib/pyplot.py", line 114, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/cm/shared/global/opt/Python-2.7.12/lib/python2.7/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
    globals(),locals(),[backend_name],0)
  File "/cm/shared/global/opt/Python-2.7.12/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 6, in <module>
    from matplotlib.externals.six.moves import tkinter as Tk
  File "/cm/shared/global/opt/Python-2.7.12/lib/python2.7/site-packages/matplotlib/externals/six.py", line 199, in load_module
    mod = mod._resolve()
  File "/cm/shared/global/opt/Python-2.7.12/lib/python2.7/site-packages/matplotlib/externals/six.py", line 113, in _resolve
    return _import_module(self.mod)
  File "/cm/shared/global/opt/Python-2.7.12/lib/python2.7/site-packages/matplotlib/externals/six.py", line 80, in _import_module
    __import__(name)
  File "/cm/shared/global/opt/Python-2.7.12/lib/python2.7/lib-tk/Tkinter.py", line 39, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
>>> 
You can use the command line option '-nogui' (this sets netpyne.__gui__ to False) to avoid importing graphic-related modules -- but you won't be able to use the most analysis functions.
Different path. Same problem.

Code: Select all

 from netpyne import specs, sim
  File "/lib/python2.7/site-packages/netpyne/sim.py", line 21, in <module>
    from .network import Network
  File "/lib/python2.7/site-packages/netpyne/network.py", line 10, in <module>
    from matplotlib.pylab import array, sin, cos, tan, exp, sqrt, mean, inf, dstack, unravel_index, argsort, zeros, ceil, copy 
  File "/lib/python2.7/site-packages/matplotlib/pylab.py", line 257, in <module>
    from matplotlib import cbook, mlab, pyplot as plt
  File "/lib/python2.7/site-packages/matplotlib/pyplot.py", line 113, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/lib/python2.7/site-packages/matplotlib/backends/__init__.py", line 60, in pylab_setup
    [backend_name], 0)
  File "/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 6, in <module>
    from six.moves import tkinter as Tk
  File "/lib/python2.7/site-packages/six.py", line 203, in load_module
    mod = mod._resolve()
  File "/lib/python2.7/site-packages/six.py", line 115, in _resolve
    return _import_module(self.mod)
  File "/lib/python2.7/site-packages/six.py", line 82, in _import_module
    __import__(name)
  File "/cm/shared/global/opt/Python-2.7.12/lib/python2.7/lib-tk/Tkinter.py", line 39, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
salvadord
Posts: 86
Joined: Tue Aug 18, 2015 3:49 pm

Re: Netpyne on clusters

Post by salvadord »

try adding this at the top of the main script you are calling:

Code: Select all

import matplotlib; matplotlib.use('Agg')
bremen
Posts: 45
Joined: Mon Apr 24, 2017 8:15 am
Location: Italy

Re: Netpyne on clusters

Post by bremen »

It worked.
Thank you.
Post Reply