Registeration issue after successfully installing petsc4py on Ubuntu18.04

Issue #140 resolved
gx t created an issue

Hi,

I ran into this issue after installing petsc and petsc4py on my Ubuntu18.04 virtual machine.

/home/tgxus34/.local/lib/python3.6/site-packages/petsc4py/lib/__init__.py:130: UserWarning: ignored arch: 'arch-linux2-c-opt', using: 'arch-linux2-c-debug'
  (os.path.pathsep.join(arch_env), arch))
Traceback (most recent call last):
  File "poisson.py", line 9, in <module>
    from tIGAr import *
  File "/home/tgxus34/tIGAr/tIGAr/__init__.py", line 1, in <module>
    from tIGAr.common import *
  File "/home/tgxus34/tIGAr/tIGAr/common.py", line 12, in <module>
    petsc4py.init(sys.argv)
  File "/home/tgxus34/.local/lib/python3.6/site-packages/petsc4py/__init__.py", line 44, in init
    PETSc._initialize(args, comm)
  File "PETSc/PETSc.pyx", line 441, in petsc4py.PETSc._initialize
  File "PETSc/PETSc.pyx", line 429, in petsc4py.PETSc.register
  File "PETSc/Object.pyx", line 265, in petsc4py.PETSc.PyPetscType_Register
ValueError: key: 0, cannot register: <class 'petsc4py.PETSc.DMLabel'>, already registered: None

I followed this tutorial: https://petsc4py.readthedocs.io/en/stable/install.html#using-pip-or-easy-install

There is one warning during the installation of petsc4py.

Keyring is skipped due to an exception: Item does not exist!

Thanks!

Comments (10)

  1. Lisandro Dalcin

    The UserWarning you are getting is a bit suspicious. Did you build PETSc yourself? What's the output of?:

    ldd /home/tgxus34/.local/lib/python3.6/site-packages/petsc4py/lib/*.so*

  2. gx t reporter

    Thanks for the quick reply!

    I don’t think I have this information stored:

    ldd: /home/tgxus34/.local/lib/python3.6/site-packages/petsc4py/lib/*.so*: No such file or directory
    

    My petsc4py/lib folder as:

    .  ..  arch-linux2-c-debug  __init__.py  petsc.cfg  __pycache__
    

    I had a working petsc installed from: https://www.mcs.anl.gov/petsc/ in my VM, so i just did the following:

    $ export PETSC_DIR=/path/to/petsc
    $ export PETSC_ARCH=arch-linux2-c-opt
    $ pip3 install petsc4py
    

  3. Lisandro Dalcin

    Oh, sorry, my bad, the ldd command to run is

    ldd /home/tgxus34/.local/lib/python3.6/site-packages/petsc4py/lib/*/*.so*
    

    Maybe you have a previous build stored in the pip cache? Can you try reinstalling?:

    $ pip uninstall --yes petsc4py
    $ export PETSC_DIR=/path/to/petsc
    $ export PETSC_ARCH=arch-linux2-c-opt
    $ pip3 install --no-cache-dir --user petsc4py
    

    PS: As you did not send the pip install output, I have no other option than guess what may be wrong. Did you install with the --user flag?

  4. gx t reporter

    This is the dependency message from ldd:

            linux-vdso.so.1 (0x00007ffff13c6000)
        libpetsc.so.3.13 => /opt/petsc/petsc/arch-linux2-c-debug/lib/libpetsc.so.3.13 (0x00007f20d0559000)
        libmpi.so.20 => /usr/lib/x86_64-linux-gnu/libmpi.so.20 (0x00007f20d0267000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f20cfe76000)
        liblapack.so.3 => /usr/lib/x86_64-linux-gnu/liblapack.so.3 (0x00007f20cf5f0000)
        libblas.so.3 => /usr/lib/x86_64-linux-gnu/libblas.so.3 (0x00007f20cf395000)
        libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f20cf05d000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f20cecbf000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f20ceabb000)
        libmpi_mpifh.so.20 => /usr/lib/x86_64-linux-gnu/libmpi_mpifh.so.20 (0x00007f20ce864000)
        libgfortran.so.4 => /usr/lib/x86_64-linux-gnu/libgfortran.so.4 (0x00007f20ce485000)
        libgcc_s.so.1 => /usr/lib/gcc/x86_64-linux-gnu/7/libgcc_s.so.1 (0x00007f20ce26d000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f20ce04e000)
        libopen-rte.so.20 => /usr/lib/x86_64-linux-gnu/libopen-rte.so.20 (0x00007f20cddc6000)
        libopen-pal.so.20 => /usr/lib/x86_64-linux-gnu/libopen-pal.so.20 (0x00007f20cdb14000)
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f20cd90c000)
        libhwloc.so.5 => /usr/lib/x86_64-linux-gnu/libhwloc.so.5 (0x00007f20cd6cf000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f20d2fc0000)
        libopenblas.so.0 => /usr/lib/x86_64-linux-gnu/libopenblas.so.0 (0x00007f20cb429000)
        libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f20cb201000)
        libquadmath.so.0 => /usr/lib/x86_64-linux-gnu/libquadmath.so.0 (0x00007f20cafc1000)
        libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f20cadbe000)
        libnuma.so.1 => /usr/lib/x86_64-linux-gnu/libnuma.so.1 (0x00007f20cabb3000)
        libltdl.so.7 => /usr/lib/x86_64-linux-gnu/libltdl.so.7 (0x00007f20ca9a9000)
        libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f20ca7a5000)
        libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f20ca59f000)
        libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f20ca38a000)
    

    I did put a --user during installation, and I tried to put it in a non-cache dir, as you suggested. The warning about Keyring is skipped due to an exception: Item does not exist!` is gone, but the same exact issue as my first post popped out when I tried a test example.

    Thanks!

  5. Lisandro Dalcin

    Note that libpetsc.so.3.13 => /opt/petsc/petsc/arch-linux2-c-debug/lib/libpetsc.so.3.13 does not match PETSC_ARCH=arch-linux2-c-opt, so something funky is going on. Or was this the ldd output BEFORE you reinstalled?

    I have no clue, honestly. Tell me something: if you run the following command in the terminal, does it work?

    python3 -m petsc4py -help
    

    If yes, what’s the output of this one?

    python3 -c "from petsc4py import PETSc; print(PETSc)"
    

  6. gx t reporter

    Thanks for the reply!

    1: The ldd outputs are AFTER my reinstallation.

    2: This command: python3 -m petsc4py -help gives a lot of help information, so I think it is working properly.

    3: This command python3 -c "from petsc4py import PETSc; print(PETSc)" provides:

    /home/tgxus34/.local/lib/python3.6/site-packages/petsc4py/lib/__init__.py:130: UserWarning: ignored arch: 'arch-linux2-c-opt', using: 'arch-linux2-c-debug'
      (os.path.pathsep.join(arch_env), arch))
    <module 'petsc4py.PETSc' (/home/tgxus34/.local/lib/python3.6/site-packages/petsc4py/lib/arch-linux2-c-debug/PETSc.cpython-36m-x86_64-linux-gnu.so)>
    

    4: Is it possible to install previous versions of petsc4py? I remember that I made successful installation months before.

    5: Do you think this resolved issue is related? https://bitbucket.org/petsc/petsc4py/issues/51/make-test-command-for-slepc4py

    Thanks!

  7. Lisandro Dalcin

    So, the fact that 2 and 4 worked just fine means that there is no problem with your petsc4py install, this is not a petsc4py issue, you have to hunt for the problem elsewhere.

    About 4, yes, you can, but if you want to install petsc4py-3.12.x, then you need petsc-3.12.y, i.e. the major.minor version numbers have to match, just ask pip for the appropriate version, our download the tarball and pip install/setup.py install it.

    About 5, well, messing with LD_LIBRARY_PATH may always be a source of problems. Anyway, keep in mind that your petsc4py seems to working just fine, the problem is elsewhere in code that uses petsc4py. For sure there is some mess around, maybe some other packages are using a different PETSc build?.

  8. gx t reporter

    Just add an update that by installing petsc-3.12.0 and petsc4py-3.12.0 solves the problem, thanks!

  9. Log in to comment