2

So I need to use mpi4py to run a module. After manually installed mpi4py and add the path to mpi4py package to python search path through sys.path.append() command in .pythonrc. And I tried to import mpi4py in the interpreter and it works fine, no matter where the interpreter is invoked:

$ python
Python 2.7.4 (default, May 23 2013, 17:15:02) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from mpi4py import MPI
>>> MPI
<module 'mpi4py.MPI' from '/home/XXXX/yt-x86_64/src/mpi4py-1.3/build/lib.linux-x86_64-2.7/mpi4py/MPI.so'>

Then I tried to run from command line which a python script containing from mpi4py import MPI. It can't find the module:

$ python run_rockstar2.py
Traceback (most recent call last):
  File "run_rockstar2.py", line 1, in <module>
    from mpi4py import MPI
ImportError: No module named mpi4py

I've checked that I'm using the same python in the two cases. Anyone has a clue about this?

Thanks in advance.

1 Answer 1

5

Your .pythonrc is only checked in interactive mode. You should add the module path to your PYTHONPATH environment variable.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, the problem is fixed!
If mpi4py is located here /Users/MYUSERNAME/anaconda/lib/python2.7/site-packages/mpi4py/__init__.pyc', where do I add this path to? I tried my .bash_profile's PATH and PYTHONPATH variables with no luck

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.