How to import neuron in Jupyter Notebook?


#1

Hi,

I tried to install NEURON in order to import it in Jupyter Notebook and I get
error: could not create ‘/usr/lib64’: Permission denied

How should I install NEURON in order to be able to import in in Jupyter Notebook?


#2

Hi,

Yes, unfortunately now it is not possible to install NEURON in the notebook as soon as it requires root privileges.
We will try to fix it somehow in the next release which should be in about two weeks from now.

Regards,
Yury


#3

Hi,

does this also hold for NEST?
Is it possible to import NEST in a Notebook?

Best,
Johanna


#4

Hi,

NEST is not installed by default in jupyter notebook environment as well.
Usually python packages can be installed from the notebook with !pip2 install command. Example
https://collab.humanbrainproject.eu/#/collab/509/nav/4946

But in case of NEST I don’t know how it is supposed to be installed. Is it a python package or something else.
I found this page
http://www.nest-simulator.org/installation/
If it is the installation process you can try to do the same from the notebook using !.

Another note. Don’t forget that at the moment notebooks are running on quite small VM and it is not supposed to be used to run code which require a lot of CPU/memory resources.

Yury


#5

When pip installing Neuron one indeed needs root access (to install in /usr/)
But Neuron can also be installed as user, when compiled from source.
I’ve been trying to create a script for it yesterday, was almost there, but unfortunately half of it was lost when my iPython notebook was not saving itself when I guess the token expired (and didn’t tell me about it).

Since Neuron and NEST are such common tools used in the HBP, I think it should be part of the default install on these VMs. And yes, indeed, we shouldn’t use too much CPU, but this would just be for quick testing to see if the code works.


#6

NEURON is installed by default since latest release.
You can find more details here
https://collab.humanbrainproject.eu/#/collab/509/nav/6058

Yury


#7

Hi Yury,

we are currently able to use NEST within the task framework by listing “bbp-hpc-2015.R2==0.0.0” among the task requirements, meaning that there is already a NEST version installed. I do not know if we can access this version from a notebook, can we?

In order to access PyNEST from within the notebooks by “import nest”, it is necessary to link NEST during installation to the available Python version. I guess that this should be done globally as described at the NEST installation page that you mentioned above:
When configuring NEST, one can use the flag --with-python and set the path to where PyNEST shall be put with --with-pynest-prefix=… to a location accessible in the search path PYTHONPATH.

Best,
Johanna


#8

Hi Johanna,

Tasks and jupyter notebooks are running independently. So when you put “bbp-hpc-2015.R2==0.0.0” to task requirements it is a “hint” to task framework to load proper module before running a task in our cluster. Jupyter notebooks are running in another separate server which doesn’t have anything in common with the cluster. And the current situation is the NEST is not provided from the box in the jupyter notebook.

I created an example showing how you can install it for yourself here:
https://collab.humanbrainproject.eu/#/collab/509/nav/6516

We will think about providing NEST from the box in the future.

Yury


#9

Hi Yury,

thanks for your answers and for creating the example notebook.
We would definitely appreciate it a lot if NEST could be installed by default. Thank you!

Best,
Johanna


#10

Hi Yury,

now I can import neuron in my jupyter notebook. What about compiling mod files? How can I do this from jupyter notebook? Any suggestions?

Best,
Carmen


#11

Hi,

There is nrnivmodl in /usr/local/nrn/x86_64/bin/nrnivmodl. So you can try to download your mod files and call it either with suprocess or like !cd ; /usr/local/nrn/x86_64/bin/nrnivmodl

Yury


#12

Hi Yuri (and other NEST users),

I have installed NEST with your example, but if I want to use some kinds of neurons (e.g. iaf_cond_exp) NEST throws an error:

> NESTError: UnknownModelName in Create_l_i: /iaf_cond_exp is not a known model name. Please check the modeldict for a list of available models. A frequent cause for this error is that NEST was compiled without the GNU Scientific Library, which is required for the conductance-based neuron models.

How can I install the GSL libraries?
I have tried the same approach as used for NEST, installing gsl-2.1, but it throws another error when I try to “make install” it.

/bin/mkdir -p ‘/usr/local/include/gsl’
/bin/mkdir: cannot create directory ‘/usr/local/include/gsl’: Permission denied
make[2]: *** [install-pkgincludeHEADERS] Error 1
make[2]: Leaving directory /home/jupyter/gsl-build/sys'* *make[1]: *** [install-am] Error 2* *make[1]: Leaving directory/home/jupyter/gsl-build/sys’
make: *** [install-recursive] Error 1

Thank you for your help!

Best,
Alberto


#13

Hi Alberto,

you can use the same value for prefix when run configure for gsl
like ./configure --prefix=$HOME/.local

and then after gsl will be installed you can set the GSL_CONFIG environment variable to the
full path to gsl-config for NEST to know where GSL is located (it will $HOME/.local/bin)

Yury


#14

Thank you Yury!

Alberto


#15

Hi, when trying to import neuron in a Python 3 workbook, I get a Python 2 syntax error:

Traceback (most recent call last):

  File "/opt/conda/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2862, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)

  File "<ipython-input-20-689dca529bf4>", line 1, in <module>
    import neuron

  File "/home/jovyan/.local/nrn/lib/python/neuron/__init__.py", line 120
    print "Enabling NEURON+Python help system."
                                              ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Enabling NEURON+Python help system.")?

#16

Hi, try loading a different neuron version

!ln -sfn /home/jovyan/.local/nrn-7.6/ /home/jovyan/.local/nrn


#17

7.6 seems to be working for Python 3. Thanks!


#18

I require the newer version of NEURON, the old one, 7.6 doesn’t seem to support nrnmpi_init, something I need to correctly initialize my MPI.

When I try to compile NEURON from source it says the BISON executable is missing, and I suspect that’s only going to be the first of many errors trying to compile it myself. Can this be fixed quickly, in time for SGA2 deadlines?

Python 3 has been the default version of Python for over 10 years, Python 3 support should be mandatory, and Python 2 support optional.

I also believe that these neuroscientist oriented tools such as the Collab should be prepared before release of new versions to be day zero adopters of new versions of common tools such as NEURON, NEST and others, or atleast give us the proper tools such as sudo access to install software, or the possibility to manage an account VM image that we can use to run our notebooks and give to others without sudo access. I hope this has been considered in Collab v2.0 :smile:


#19

@RobinDe you should open a ticket at support@humanbrainproject.eu and if you require the newer version because you are implementing a new usecase in the Brain Simulation Platform, you should open a ticket at https://github.com/cnr-ibf-pa/hbp-bsp-issues