Question

import nest gives the 'no module named nest' error when it is in the $PATH, which means that there is a /opt/nest/lib/python2.7/site-packages: in my system $PATH. At this location there is a directory named nest and the structure inside the nest directory is looks like:

enter image description here

, where there is an __init__.py obviously. So why can't python find nest?

more information:

I am sure that I installed nest with python2.7, and run it with the same python2.7.

Was it helpful?

Solution

According to the docs, there are several ways to install python packages:

  1. using distutils - running python setup.py install installs the package to site-packages of your current distribution;
  2. passing --user to setup.py install installs module to ~/.local/lib/python2.7/site-packages on Unix, and this directory in under normal conditions always included in sys.path;
  3. passing --home=$HOME to setup.py install installs module under $HOME directory. This directory should be included to sys.path explicitly;
  4. modifying python search path:

you can do either

   import sys
   sys.path.append('/opt/nest/lib/python2.7/site-packages')

in the beginning of your script; or your can add

PYTHONPATH=/opt/nest/lib/python2.7/site-packages
export PYTHONPATH

in the end of your ~/.bash_profile file.

UPDATE:

Just tried to install nest and found that it comes in two flavours - 32bit (under /opt/nest/lib) and 64bit (under /opt/nest/lib64). You might have tried to use 32-bit python package with 64-bit python distribution. Try to change the string in ./zshrc to PYTHONPATH=/opt/nest/lib64/python2.7/site-packages and see if it works. It works for me at least.

OTHER TIPS

To set relevant environment variables correctly, NEST installs have a config that you can just source

source <installpath>/bin/nest_vars.sh

That sets the PATH and PYTHONPATH correctly and points NEST to the right directories for dynamically loaded content (modules, help pages, …)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top