Installing getfem++ from the source code under Linux and python 3 environment.

I had had a problem installing getfem++ with python 3. And here is the solution

Environment
OS : Ubuntu 18.04 x64 under Windows Subsystem for Linux (WSL)
Python : Python 3.7.6 (under Anaconda)
getfem : getfem++ 5.3


1. Install dependencies and Anaconda

sudo apt install libatlas-base-dev libblas-dev liblapack-dev libmumps-seq-dev libqhull-dev gfortran

https://docs.anaconda.com/anaconda/install/linux/

2. Download getfem++ from getfem download page

http://getfem.org/download.html

3. Build library

make

(see also http://getfem.org/install/install_linux.html)

4. Install library

sudo make install


(see also http://getfem.org/install/install_linux.html)

5. Check getfem python package location
* The file name of the shared library file may differ depending on your python and Linux version.

After installing library and I tried to run demo file in (getfem install directory/interface/tests/python). But it immediately displayed an error message

No module named 'getfem'

The problem was that the module was installed somewhere not in PYTHONPATH variable which you could find by running

echo $PYTHONPATH

or in the python interpreter

import sys
sys.path

In my case, this module was placed in /usr/local/lib/python3.7/site-packages

which is not the place where Anaconda's python modules are located.

So I move getfem folder into

~/anaconda3/lib/python3.7/site-packages/

Alternatively you could just add the default install folder to PYTHONPATH variable in ~/.proflie

export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.7/site-packages


6. Modify the __init__.py

And I ran the demo file again, but it still produced an error saying that
there is no MesherObject in getfem module.

It turned out that a problem was incurred in __init__.py from

from getfem import *


which was intended to import all attributes in getfem.py .
Since the file the module try to access is getfem.py in getfem directory the correct code instead has to be

from getfem.getfem import *


8. Place the shared library file at the proper location.

Another problem was incurred during

from _getfem import *

which looks for the shared library in my case _getfem.cpython-37m-x86_64-linux-gnu.so

that could be found in (getfem source directory)/interface/src/python

I copied this file to /anaconda3/lib/python3.7/site-packages/ . And this could file could be anywhere in paths in PYTHONPATH variable in sys.path.

Then, I finally got to run demo files.

댓글

  1. 작성자가 댓글을 삭제했습니다.

    답글삭제
  2. I tried the package manager first by the following command but it ended up with python 2.

    sudo apt install python-getfem++

    답글삭제

댓글 쓰기

이 블로그의 인기 게시물

빈 플랜트 가찌아 호환 58 mm 바텀리스 포터필터, 디스트리뷰터

오디세이 OLED G9 모니터

How to solve Logi Options + Backend Connection Problem