pets4py + pets v.2

Issue #86 closed
Former user created an issue

Dear Lisandro and all,

I have finished the installation and it seems to me that it finished well. Hovewer, I have few problems which are fatal for utilisation:

  1. No petsc4py.help file, so, I cannot check if it works
  2. When I write python3 -c "import petsc4py", being in my enviroment (I installed everything there), I obtain the following error:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named 'petsc4py'

When I quit the enviroment and type the same command, I do not obtain any error... 3. So, I quit the env and try to launch the tests/ WHen I type python3 ./runtests.py, I obtain:

Traceback (most recent call last):
  File "./runtests.py", line 216, in <module>
    sys.exit(main())
  File "./runtests.py", line 203, in main
    package = import_package(options, pkgname)
  File "./runtests.py", line 85, in import_package
    package.init(args, arch=options.arch)
  File "/home/ivan/.local/lib/python3.5/site-packages/petsc4py/__init__.py", line 42, in init
    PETSc = petsc4py.lib.ImportPETSc(arch)
  File "/home/ivan/.local/lib/python3.5/site-packages/petsc4py/lib/__init__.py", line 29, in ImportPETSc
    return Import('petsc4py', 'PETSc', path, arch)
  File "/home/ivan/.local/lib/python3.5/site-packages/petsc4py/lib/__init__.py", line 64, in Import
    with f: module = imp.load_module(fullname, f, fn, info)
  File "/usr/lib/python3.5/imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic
    return _load(spec)
  File "<frozen importlib._bootstrap>", line 693, in _load
  File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 577, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 906, in create_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "PETSc/PETSc.pyx", line 109, in init petsc4py.PETSc
RuntimeError: module compiled against API version 0xc but this version of numpy is 0xa

Have you got any idea?

P.S. config is - Ubuntu 16.04 - x86_64 - PETSc 3.8 - Petsc4py 3.8

Thanks!

Comments (9)

  1. Lisandro Dalcin

    What do you mean with env ? Are you trying to install in a virtual environment? Can you write down the exact steps needed to reproduce your issue? Do you have multiple versions of NumPy installed? It seems that petsc4py was built with some numpy version, but then at runtime a newer version is being imported. However, the numpy issue may be petsc4py's fault. Any chance you can use branch maint of a petsc4py git clone (it should work fine with any PETSc 3.8 release) ?

  2. Ivan VOZNYUK

    Hi Lisandro, Thx for your reply.

    By env, I mean virtual environment (VE). Yes, indeed, I am trying to install the pytsc4py in my VE (source path/to/bin/activate). I checked and it turned out indeed that the version of numpy in my VE is not equal to the version of numpy installed on my PC initially (1.14.0 vs 1.11.0).

  3. Ivan VOZNYUK

    The exact steps needed to reproduce the issue:

    cd path/to/petsc4py-3.8.1/test/
    python3 runtests.py 
    

    Yields me this:

    ivan@mwi1:~/Work/01.Programms/petsc4py-3.8.1/test$ python3 runtests.py 
    Traceback (most recent call last):
      File "runtests.py", line 216, in <module>
        sys.exit(main())
      File "runtests.py", line 203, in main
        package = import_package(options, pkgname)
      File "runtests.py", line 85, in import_package
        package.init(args, arch=options.arch)
      File "/home/ivan/.local/lib/python3.5/site-packages/petsc4py/__init__.py", line 42, in init
        PETSc = petsc4py.lib.ImportPETSc(arch)
      File "/home/ivan/.local/lib/python3.5/site-packages/petsc4py/lib/__init__.py", line 29, in ImportPETSc
        return Import('petsc4py', 'PETSc', path, arch)
      File "/home/ivan/.local/lib/python3.5/site-packages/petsc4py/lib/__init__.py", line 64, in Import
        with f: module = imp.load_module(fullname, f, fn, info)
      File "/usr/lib/python3.5/imp.py", line 242, in load_module
        return load_dynamic(name, filename, file)
      File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic
        return _load(spec)
      File "<frozen importlib._bootstrap>", line 693, in _load
      File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
      File "<frozen importlib._bootstrap>", line 577, in module_from_spec
      File "<frozen importlib._bootstrap_external>", line 906, in create_module
      File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
      File "PETSc/PETSc.pyx", line 109, in init petsc4py.PETSc
    RuntimeError: module compiled against API version 0xc but this version of numpy is 0xa
    

    Than, I go to the virtual environment (as all of my packages are installed there) and relaunch the tests:

    source path/to/bin/activate
    python3 runtests.py
    

    This gives the following error:

    Traceback (most recent call last):
      File "runtests.py", line 216, in <module>
        sys.exit(main())
      File "runtests.py", line 203, in main
        package = import_package(options, pkgname)
      File "runtests.py", line 84, in import_package
        package = __import__(pkgname)
    ImportError: No module named 'petsc4py'
    
  4. Lisandro Dalcin

    Well, I guess that if you reinstall petsc4py from branch maint of the git repo, the numpy issue should be fixed. However, please note that if you install petsc4py in a virtual env, then you should run the tests with that virtual env activated (also, after installing, it is a good idea to remove the build/ directory before running the tests, to make sure you run with the installed files, and not the ones in the build/ directory, which is the default behavior).

  5. Ivan VOZNYUK

    Hi Lisandro,

    The problem is that if I run the tests from my virtual environment, I obtain the error ImportError: No module named 'petsc4py', as I precised above. Although, it should recognize it, as I installed it right there...

  6. Ivan VOZNYUK

    In fact, I advanced in the intallation. What I ve done:

    1. Updated locally numpy, installed locally Cython.
    2. Git clone the petsc4py, then checkout maint. Installed it outside the virtual env.
    3. Tried to insstall petsc4py inside my virt.env - and failed, cause apperently it intalles always outside of the virt.env.
    4. So tests are running from locally (ouside the virt.env) and inside virt.env, python does not know import petsc4py.
    5. To solve this problem I just copied /usr/local/lib/python3.5/dist-packages/ inside /path/to/virtual.env/lib/python3/site-packages

    And it works! So thx a lot, Lisandro, for your valuable help!

  7. Ivan VOZNYUK

    My last question for you is going to concern the tests from petsc4py/test/

    When I run python3 ./runtests.py I obtain (at the end) the following error:

    ======================================================================
    ERROR: testSetMPIGhost (test_vec.TestVecWithArray)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "./test_vec.py", line 267, in testSetMPIGhost
        v = PETSc.Vec().create()
      File "PETSc/Vec.pyx", line 146, in petsc4py.PETSc.Vec.create
    petsc4py.PETSc.Error: error code 1
    [0] VecCreate() line 35 in /home/ivan/Work/01.Programms/petsc/src/vec/vec/interface/veccreate.c
    [0] PetscHeaderCreate_Private() line 57 in /home/ivan/Work/01.Programms/petsc/src/sys/objects/inherit.c
    [0] PetscCommDuplicate() line 132 in /home/ivan/Work/01.Programms/petsc/src/sys/objects/tagm.c
    [0] MatZeroEntries() line 5579 in /home/ivan/Work/01.Programms/petsc/src/mat/interface/matrix.c
    [0] MatZeroEntries_Python() line 2987 in src/libpetsc4py/libpetsc4py.c
    [0]   
    [0] method zeroEntries()
    
    ----------------------------------------------------------------------
    Ran 4114 tests in 41.733s
    
    FAILED (errors=1)
    [ 0]1504 bytes VecCreate() line 35 in /home/ivan/Work/01.Programms/petsc/src/vec/vec/interface/veccreate.c
          [0]  VecCreate() line 35 in /home/ivan/Work/01.Programms/petsc/src/vec/vec/interface/veccreate.c
          [0]  MatZeroEntries() line 5570 in /home/ivan/Work/01.Programms/petsc/src/mat/interface/matrix.c
          [0]  MatDiagonalSet() line 235 in /home/ivan/Work/01.Programms/petsc/src/mat/utils/axpy.c
          [0]  MatMultTranspose() line 2391 in /home/ivan/Work/01.Programms/petsc/src/mat/interface/matrix.c
          [0]  MatMult() line 2335 in /home/ivan/Work/01.Programms/petsc/src/mat/interface/matrix.c
          [0]  MatGetDiagonal() line 4494 in /home/ivan/Work/01.Programms/petsc/src/mat/interface/matrix.c
          [0]  MatDiagonalScale() line 4992 in /home/ivan/Work/01.Programms/petsc/src/mat/interface/matrix.c
          [0]  MatZeroEntries() line 5570 in /home/ivan/Work/01.Programms/petsc/src/mat/interface/matrix.c
          [0]  MatDiagonalSet() line 235 in /home/ivan/Work/01.Programms/petsc/src/mat/utils/axpy.c
          [0]  MatMultTranspose() line 2391 in /home/ivan/Work/01.Programms/petsc/src/mat/interface/matrix.c
          [0]  MatMultTranspose() line 2391 in /home/ivan/Work/01.Programms/petsc/src/mat/interface/matrix.c
          [0]  MatDiagonalScale() line 4992 in /home/ivan/Work/01.Programms/petsc/src/mat/interface/matrix.c
          [0]  MatMultTranspose() line 2391 in /home/ivan/Work/01.Programms/petsc/src/mat/interface/matrix.c
          [0]  MatMultTranspose() line 2391 in /home/ivan/Work/01.Programms/petsc/src/mat/interface/matrix.c
    

    Have you got any idea? Thx!

  8. Lisandro Dalcin

    I'll need to take a closer look at the error you reported. I guess you can ignore it for now.

  9. Log in to comment