This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Problem to use PyTrilinos

0 votes

I am trying to use run the tutorial with preconditioners and is needed PyTrilinos.
I have installed trilinos with PyTrilinos in a custome directory but python does not aware of the module.

from PyTrilinos import Epetra, AztecOO, TriUtils, ML
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named PyTrilinos

The installation of trilinos was done in this directory

~/trilinos-install/

I see the pakages of PyTrilinos in

~/trilinos-install/lib/python2.7/site-packages/PyTrilinos

is there another step to link python to the module ?

asked Jun 19, 2014 by user478 FEniCS Novice (230 points)

1 Answer

+1 vote
 
Best answer

This is really a Python question, not a FEniCS question so probably not the right forum here. Anyway, if you install a Python module in a non-standard location you need to adjust the environment variable PYTHONPATH accordingly. If you are using bash you can try the following:

export PYTHONPATH=$PYTHONPATH:~/trilinos-install/lib/python2.7/site-packages

If you then import PyTrilinos again it should hopefully work. Note that the changes will be lost if you exit your current shell, so if you want them to be persistent you need to add the above line somewhere in your ~/.bashrc file.

answered Jun 19, 2014 by Maximilian Albert FEniCS User (1,750 points)
selected Jun 19, 2014 by user478

I exported

export PYTHONPATH=$PYTHONPATH:~/trilinos-install/lib/python2.7/site-packages

and aditionally indicated the trilinos lib exporting the varibale LD_LIBRARY_PATH

export LD_LIBRARY_PATH=~/trilinos-install/lib:$LD_LIBRARY_PATH

and the import is now well

from PyTrilinos import Epetra, AztecOO, TriUtils, ML

However following again the tutorial with preconditioners says now the has_la_backend does not exists even thoug the fecnics is completely import (from dolfin import *). Where is that function?

Traceback (most recent call last):
  File "Documents/solver.py", line 19, in <module>
    if not has_la_backend('Epetra'):
NameError: name 'has_la_backend' is not defined

I just checked and it looks like this function has been renamed to has_linear_algebra_backend. It seems that the documentation is not up to date in this respect. You may want to file a bug in the issue tracker for the documentation.

Thanks a lot, I have created a new issue for the correction.

But now return false with Epetra

>>> has_linear_algebra_backend('Epetra')
 False

I Proved with petcs and is ok

>>> has_linear_algebra_backend('PETSc')
True

and compiled trilinos with epetra

-D Trilinos_ENABLE_Epetra:BOOL=ON \  
-D Trilinos_ENABLE_EpetraExt:BOOL=ON \

epectra is in PyTrilinos

from PyTrilinos import Epetra

is it necessary another configuration to recognize Epetra?

Sorry, I don't know the answer to this. Just a random guess: might it be necessary to compile dolfin itself with Trilinos and Epetra enabled? Anyway, this sort of question should probably be posted on the fenics-support mailing list (see here).

Thanks, the problem was solved using the dorsal installation

...