Manual Installation of NEURON Python module on Linux Mint 18

When Python is the interpreter, what is a good
design for the interface to the basic NEURON
concepts.

Moderator: hines

Post Reply
Darth_Malloc
Posts: 4
Joined: Tue Jun 05, 2018 4:34 pm

Manual Installation of NEURON Python module on Linux Mint 18

Post by Darth_Malloc » Fri Jun 15, 2018 11:54 am

Hi all,

So I am trying to do a manual installation of the NEURON Python module on Linux Mint 18. The reason that I am doing installing it that way is that I tried installing from the .deb, and I got an import error.

when I try to install manually using setup.py, I get the following message:

running install
running build
running build_py
Traceback (most recent call last):
File "setup.py", line 131, in <module>
ext_modules=ext_modules
File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/lib/python2.7/distutils/command/install.py", line 601, in run
self.run_command('build')
File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/lib/python2.7/distutils/command/build.py", line 128, in run
self.run_command(cmd_name)
File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/usr/lib/python2.7/distutils/dist.py", line 971, in run_command
cmd_obj.ensure_finalized()
File "/usr/lib/python2.7/distutils/cmd.py", line 109, in ensure_finalized
self.finalize_options()
File "/usr/lib/python2.7/distutils/command/build_py.py", line 55, in finalize_options
for name, path in self.distribution.package_dir.items():
AttributeError: 'set' object has no attribute 'items'

Based on this error, it looks as though setup.py was not written properly. I would greatly appreciate if anyone has any suggests regarding how I can fix this. I need the NEURON Python module for a school project.

ted
Site Admin
Posts: 5369
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Manual Installation of NEURON Python module on Linux Mint 18

Post by ted » Fri Jun 15, 2018 9:44 pm

I am trying to do a manual installation of the NEURON Python module
What NEURON Python module? One you picked up somewhere, or what?

Darth_Malloc
Posts: 4
Joined: Tue Jun 05, 2018 4:34 pm

Re: Manual Installation of NEURON Python module on Linux Mint 18

Post by Darth_Malloc » Sat Jun 16, 2018 12:11 am

Sorry for the ambiguity. I am trying to install the Python module that comes with the NEURON platform. I am trying to get the module to install into in the correct folder so that it imports properly.

ted
Site Admin
Posts: 5369
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Manual Installation of NEURON Python module on Linux Mint 18

Post by ted » Sun Jun 17, 2018 11:24 am

I just installed NEURON under Mint18.3 just 2 weeks ago, and setup.py ran without problems. I started with the latest development source code from Github and allowed NEURON to be installed into its default location /usr/local/nrn. Of couse that required invoking sudo for the make install steps, and also for the setup.py install step. What source code did you use, and where did you install NEURON?

Darth_Malloc
Posts: 4
Joined: Tue Jun 05, 2018 4:34 pm

Re: Manual Installation of NEURON Python module on Linux Mint 18

Post by Darth_Malloc » Sun Jun 17, 2018 1:41 pm

Thank you very much for your reply. That sounds like the same procedure that I tried to follow. Did you run setup.py through Python 3.5 or Python 2.7? I was also wondering if there are any environmental variables that need to be set or installation option flags that need to be selected in order for the NEURON Python module to run.

ted
Site Admin
Posts: 5369
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Manual Installation of NEURON Python module on Linux Mint 18

Post by ted » Sun Jun 17, 2018 3:36 pm

For this particular installation, I did
sudo python3 setup.py install

I use NEURON and idraw from the command line, so in .bashrc I inserted
PATH= $PATH:/usr/local/iv/x86_64/bin:/usr/local/nrn/x86_64/bin

If you plan to launch Python and import nrn, you'll need to specify PYTHONPATH
A correct statement to set the PYTHONPATH will be something like
export PYTHONPATH=/where/you/installed/neuron/lib/python
The '/where/you/installed/neuron' would be the --prefix you specified with configure. In the case of installation to the default location /usr/local/nrn, the statement would be
export PYTHONPATH=/usr/local/nrn/lib/python

Darth_Malloc
Posts: 4
Joined: Tue Jun 05, 2018 4:34 pm

Re: Manual Installation of NEURON Python module on Linux Mint 18

Post by Darth_Malloc » Sun Jun 17, 2018 6:08 pm

I tried following the steps as you described them, but now I am getting this error:

Traceback (most recent call last):
File "setup.py", line 132, in <module>
ext_modules=ext_modules
File "/usr/lib/python3.5/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.5/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib/python3.5/distutils/command/install.py", line 583, in run
self.run_command('build')
File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib/python3.5/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib/python3.5/distutils/command/build_ext.py", line 338, in run
self.build_extensions()
File "/usr/lib/python3.5/distutils/command/build_ext.py", line 447, in build_extensions
self._build_extensions_serial()
File "/usr/lib/python3.5/distutils/command/build_ext.py", line 472, in _build_extensions_serial
self.build_extension(ext)
File "/usr/lib/python3.5/distutils/command/build_ext.py", line 557, in build_extension
target_lang=language)
File "/usr/lib/python3.5/distutils/ccompiler.py", line 717, in link_shared_object
extra_preargs, extra_postargs, build_temp, target_lang)
File "/usr/lib/python3.5/distutils/unixccompiler.py", line 170, in link
libraries)
File "/usr/lib/python3.5/distutils/ccompiler.py", line 1089, in gen_lib_options
lib_opts.append(compiler.library_dir_option(dir))
File "/usr/lib/python3.5/distutils/unixccompiler.py", line 218, in library_dir_option
return "-L" + dir
TypeError: Can't convert 'list' object to str implicitly

Is there a change that I can make in setup.py so that the installation will run correctly?

ted
Site Admin
Posts: 5369
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Manual Installation of NEURON Python module on Linux Mint 18

Post by ted » Wed Jun 20, 2018 10:35 am

What worked for Mint18.3

Delete the NEURON and InterViews source code and whatever is installed.
Then follow this recipe (copy and paste is safest).

0. Apply the latest updates to Mint.

1. Make sure the software development environment is adequate.
Some or all of these may already be present on your machine, but it never hurts to make sure.
sudo apt install build-essential
sudo apt install bison flex automake libtool
sudo apt install libx11-dev libxext-dev
sudo apt install libncurses-dev xfonts-100dpi
sudo apt install python-dev zlib1g-dev
sudo apt install git

2. Prepare directories for NEURON and InterViews source code and installation.
For the sake of convenience, put these in your home directory.
cd ~
mkdir bin installed
cd installed
mkdir neuron
cd neuron
mkdir repos
cd repos

3. Install InterViews.
Get the latest development code for InterViews:

git clone https://github.com/nrnhines/iv
cd iv
./build.sh
./config.guess
./configure --prefix=/home/yourname/bin/iv
where of course yourname is your login name

make
make install

Test:
cd ~/bin/iv
./idraw
File/quit when done.

4. Install NEURON
Get the latest development code for NEURON:

cd ~/installed/neuron/repos
git clone https://github.com/nrnhines/nrn
cd nrn
./build.sh
./configure --prefix=/home/yourname/bin/nrn --with-iv=/home/yourname/bin/iv --with-nrnpython=/usr/bin/python
make
make install

cd src/nrnpython
sudo python setup.py install

At end of setup.py execution, reports
Writing /usr/local/lib/python2.7/dist-packages/NEURON-7.6.egg-info
Test NEURON:
cd ~/bin/nrn/x86_64/bin
./neurondemo
Choose the "Release" and click on Init & Run
Verify that the graphs show traces of ica, cai, v.
When done, NEURON Main Menu / File / Quit

5. Update $PATH
cd ~
cp .bashrc BASHRC_0
cp BASHRC_0 BASHRC_1

Append these two lines to the end of BASHRC_1:
PATH=$PATH:$HOME/bin/iv/x86_64/bin:$HOME/bin/nrn/x86_64/bin
export PATH

Then write BASHRC_1 to disk and
cp BASHRC_1 .bashrc

Logout, then login.

6. Tests and usage
nrniv -python
or
nrngui -python
should bring up NEURON with Python as its interpreter.
The latter will load the standard run library and bring up the NEURON Main Menu toolbar.

python
from neuron import h
will launch Python, then import NEURON's h module by itself (more or less equivalent to nrniv -python)
and
python
from neuron import h,gui
will launch Python, then import NEURON's h and gui modules (more or less equivalent to nrngui -python).

Post Reply