undefined symbol: PetscOptionsSetFromOptions when installing petsc4py
I installed the PETSc package through the following steps (since pip install petsc didn't work):
- Download PETSc source using
git clone -b release https://gitlab.com/petsc/petsc.git petsc(as of today, so the version should be 3.14) ./configure --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --download-mpich --download-fblaslapack- Then, from a pipenv environment with python 3.7.5 I installed (with no error)
pip install petsc4py.
Now, python -c "from petsc4py import PETSc" raises
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/vladimir/.local/share/virtualenvs/swir-contagion-Pl26wHvZ/lib/python3.7/site-packages/petsc4py/PETSc.py", line 3, in <module>
PETSc = ImportPETSc(ARCH)
File "/home/vladimir/.local/share/virtualenvs/swir-contagion-Pl26wHvZ/lib/python3.7/site-packages/petsc4py/lib/__init__.py", line 29, in ImportPETSc
return Import('petsc4py', 'PETSc', path, arch)
File "/home/vladimir/.local/share/virtualenvs/swir-contagion-Pl26wHvZ/lib/python3.7/site-packages/petsc4py/lib/__init__.py", line 73, in Import
module = import_module(pkg, name, path, arch)
File "/home/vladimir/.local/share/virtualenvs/swir-contagion-Pl26wHvZ/lib/python3.7/site-packages/petsc4py/lib/__init__.py", line 58, in import_module
with f: return imp.load_module(fullname, f, fn, info)
File "/home/vladimir/.local/share/virtualenvs/swir-contagion-Pl26wHvZ/lib/python3.7/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/home/vladimir/.local/share/virtualenvs/swir-contagion-Pl26wHvZ/lib/python3.7/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: /home/vladimir/.local/share/virtualenvs/swir-contagion-Pl26wHvZ/lib/python3.7/site-packages/petsc4py/lib/arch-linux-c-debug/PETSc.cpython-37m-x86_64-linux-gnu.so: undefined symbol: PetscOptionsSetFromOptions
I don't know why this error is showing up. I had installed petsc and petsc4py this way a few months ago and it went smoothly