Skip to content

ERROR: Failed building wheel for petsc

I working on WSL2-ubuntu 20.04 and I am trying to automate the installation of petsc and petsc4py in my project. However, I facing following error:

make[2]: Entering directory '/home/ygandhi/paralleltopologyoptimization/plexus'
test -d build/Linux-x86_64/venv || make create-venv
make[3]: Entering directory '/home/ygandhi/paralleltopologyoptimization/plexus'
test -d build/Linux-x86_64 || mkdir -p build/Linux-x86_64
which python3 || apt install -y python3 python3-pip python3-wheel
/usr/bin/python3
test -d build/Linux-x86_64/venv || python3 -m venv build/Linux-x86_64/venv
make[3]: Leaving directory '/home/ygandhi/paralleltopologyoptimization/plexus'
Installing wheel...
/home/ygandhi/paralleltopologyoptimization/plexus/build/Linux-x86_64/venv/bin/python3 -m pip install wheel
Collecting wheel
  Using cached wheel-0.36.2-py2.py3-none-any.whl (35 kB)
Installing collected packages: wheel
Successfully installed wheel-0.36.2
PETSC_CONFIGURE_OPTIONS="--with-fc=0 --download-metis=1 --download-parmetis=1" \
/home/ygandhi/paralleltopologyoptimization/plexus/build/Linux-x86_64/venv/bin/python3 -m pip install -r requirements.txt || touch /home/ygandhi/paralleltopologyoptimization/plexus/build/Linux-x86_64/venv/bin/activate
Looking in indexes: https://pypi.python.org/simple/
Obtaining file:///home/ygandhi/paralleltopologyoptimization/plexus (from -r requirements.txt (line 3))
Collecting setuptools~=39.0.1
  Using cached setuptools-39.0.1-py2.py3-none-any.whl (569 kB)
Collecting pytest~=6.1.2
  Using cached pytest-6.1.2-py3-none-any.whl (272 kB)
Collecting click~=7.1.2
  Using cached click-7.1.2-py2.py3-none-any.whl (82 kB)
Collecting numpy~=1.19.4
  Using cached numpy-1.19.5-cp38-cp38-manylinux2010_x86_64.whl (14.9 MB)
Collecting matplotlib~=3.3.3
  Using cached matplotlib-3.3.4-cp38-cp38-manylinux1_x86_64.whl (11.6 MB)
Collecting scipy~=1.5.4
  Using cached scipy-1.5.4-cp38-cp38-manylinux1_x86_64.whl (25.8 MB)
Collecting petsc4py~=3.12.0
  Using cached petsc4py-3.12.0.tar.gz (1.8 MB)
Collecting numba~=0.51.2
  Using cached numba-0.51.2-cp38-cp38-manylinux2014_x86_64.whl (3.1 MB)
Collecting meshio~=4.3.5
  Using cached meshio-4.3.13-py3-none-any.whl (154 kB)
Processing /home/ygandhi/.cache/pip/wheels/ff/61/0c/c516bd6b85f61f0acf333b0fbf5102fe39928a3563bf245a88/mpi4py-3.0.3-cp38-cp38-linux_x86_64.whl
Collecting coverage
  Using cached coverage-5.5-cp38-cp38-manylinux2010_x86_64.whl (245 kB)
Collecting flake8
  Using cached flake8-3.9.2-py2.py3-none-any.whl (73 kB)
Collecting petsc==3.12.4
  Using cached petsc-3.12.4.tar.gz (14.2 MB)
Collecting pybind11
  Using cached pybind11-2.7.1-py2.py3-none-any.whl (200 kB)
Collecting sphinx
  Using cached Sphinx-4.1.2-py3-none-any.whl (2.9 MB)
Collecting sympy
  Using cached sympy-1.8-py3-none-any.whl (6.1 MB)
Collecting iniconfig
  Using cached iniconfig-1.1.1-py2.py3-none-any.whl (5.0 kB)
Collecting packaging
  Using cached packaging-21.0-py3-none-any.whl (40 kB)
Collecting attrs>=17.4.0
  Using cached attrs-21.2.0-py2.py3-none-any.whl (53 kB)
Collecting py>=1.8.2
  Using cached py-1.10.0-py2.py3-none-any.whl (97 kB)
Collecting toml
  Using cached toml-0.10.2-py2.py3-none-any.whl (16 kB)
Collecting pluggy<1.0,>=0.12
  Using cached pluggy-0.13.1-py2.py3-none-any.whl (18 kB)
Collecting kiwisolver>=1.0.1
  Using cached kiwisolver-1.3.1-cp38-cp38-manylinux1_x86_64.whl (1.2 MB)
Collecting pillow>=6.2.0
  Using cached Pillow-8.3.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (3.0 MB)
Collecting cycler>=0.10
  Using cached cycler-0.10.0-py2.py3-none-any.whl (6.5 kB)
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3
  Using cached pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
Collecting python-dateutil>=2.1
  Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
Collecting llvmlite<0.35,>=0.34.0.dev0
  Using cached llvmlite-0.34.0-cp38-cp38-manylinux2010_x86_64.whl (24.6 MB)
Collecting mccabe<0.7.0,>=0.6.0
  Using cached mccabe-0.6.1-py2.py3-none-any.whl (8.6 kB)
Collecting pyflakes<2.4.0,>=2.3.0
  Using cached pyflakes-2.3.1-py2.py3-none-any.whl (68 kB)
Collecting pycodestyle<2.8.0,>=2.7.0
  Using cached pycodestyle-2.7.0-py2.py3-none-any.whl (41 kB)
Collecting sphinxcontrib-applehelp
  Using cached sphinxcontrib_applehelp-1.0.2-py2.py3-none-any.whl (121 kB)
Collecting sphinxcontrib-htmlhelp>=2.0.0
  Using cached sphinxcontrib_htmlhelp-2.0.0-py2.py3-none-any.whl (100 kB)
Collecting babel>=1.3
  Using cached Babel-2.9.1-py2.py3-none-any.whl (8.8 MB)
Collecting Jinja2>=2.3
  Using cached Jinja2-3.0.1-py3-none-any.whl (133 kB)
Collecting sphinxcontrib-devhelp
  Using cached sphinxcontrib_devhelp-1.0.2-py2.py3-none-any.whl (84 kB)
Collecting sphinxcontrib-qthelp
  Using cached sphinxcontrib_qthelp-1.0.3-py2.py3-none-any.whl (90 kB)
Collecting Pygments>=2.0
  Using cached Pygments-2.9.0-py3-none-any.whl (1.0 MB)
Collecting docutils<0.18,>=0.14
  Using cached docutils-0.17.1-py2.py3-none-any.whl (575 kB)
Collecting alabaster<0.8,>=0.7
  Using cached alabaster-0.7.12-py2.py3-none-any.whl (14 kB)
Collecting sphinxcontrib-jsmath
  Using cached sphinxcontrib_jsmath-1.0.1-py2.py3-none-any.whl (5.1 kB)
Collecting sphinxcontrib-serializinghtml>=1.1.5
  Using cached sphinxcontrib_serializinghtml-1.1.5-py2.py3-none-any.whl (94 kB)
Collecting requests>=2.5.0
  Using cached requests-2.26.0-py2.py3-none-any.whl (62 kB)
Collecting imagesize
  Using cached imagesize-1.2.0-py2.py3-none-any.whl (4.8 kB)
Collecting snowballstemmer>=1.1
  Using cached snowballstemmer-2.1.0-py2.py3-none-any.whl (93 kB)
Collecting mpmath>=0.19
  Using cached mpmath-1.2.1-py3-none-any.whl (532 kB)
Collecting six
  Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting pytz>=2015.7
  Using cached pytz-2021.1-py2.py3-none-any.whl (510 kB)
Collecting MarkupSafe>=2.0
  Using cached MarkupSafe-2.0.1-cp38-cp38-manylinux2010_x86_64.whl (30 kB)
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.python.org', port=443): Read timed out. (read timeout=15)")': /simple/charset-normalizer/
Collecting charset-normalizer~=2.0.0; python_version >= "3"
  Using cached charset_normalizer-2.0.4-py3-none-any.whl (36 kB)
Collecting certifi>=2017.4.17
  Using cached certifi-2021.5.30-py2.py3-none-any.whl (145 kB)
Collecting idna<4,>=2.5; python_version >= "3"
  Using cached idna-3.2-py3-none-any.whl (59 kB)
Collecting urllib3<1.27,>=1.21.1
  Using cached urllib3-1.26.6-py2.py3-none-any.whl (138 kB)
Building wheels for collected packages: petsc4py, petsc
  Building wheel for petsc4py (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/ygandhi/paralleltopologyoptimization/plexus/build/Linux-x86_64/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-m5ldeeqw/petsc4py/setup.py'"'"'; __file__='"'"'/tmp/pip-install-m5ldeeqw/petsc4py/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-7fh20g6a
       cwd: /tmp/pip-install-m5ldeeqw/petsc4py/
  Complete output (27 lines):
  running bdist_wheel
  PETSC_DIR not specified
  running build
  running build_src
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.8
  creating build/lib.linux-x86_64-3.8/petsc4py
  copying src/PETSc.py -> build/lib.linux-x86_64-3.8/petsc4py
  copying src/__init__.py -> build/lib.linux-x86_64-3.8/petsc4py
  copying src/__main__.py -> build/lib.linux-x86_64-3.8/petsc4py
  creating build/lib.linux-x86_64-3.8/petsc4py/lib
  copying src/lib/__init__.py -> build/lib.linux-x86_64-3.8/petsc4py/lib
  creating build/lib.linux-x86_64-3.8/petsc4py/include
  creating build/lib.linux-x86_64-3.8/petsc4py/include/petsc4py
  copying src/include/petsc4py/numpy.h -> build/lib.linux-x86_64-3.8/petsc4py/include/petsc4py
  copying src/include/petsc4py/petsc4py.h -> build/lib.linux-x86_64-3.8/petsc4py/include/petsc4py
  copying src/include/petsc4py/petsc4py.PETSc.h -> build/lib.linux-x86_64-3.8/petsc4py/include/petsc4py
  copying src/include/petsc4py/petsc4py.PETSc_api.h -> build/lib.linux-x86_64-3.8/petsc4py/include/petsc4py
  copying src/include/petsc4py/petsc4py.i -> build/lib.linux-x86_64-3.8/petsc4py/include/petsc4py
  copying src/include/petsc4py/PETSc.pxd -> build/lib.linux-x86_64-3.8/petsc4py/include/petsc4py
  copying src/include/petsc4py/__init__.pxd -> build/lib.linux-x86_64-3.8/petsc4py/include/petsc4py
  copying src/include/petsc4py/__init__.pyx -> build/lib.linux-x86_64-3.8/petsc4py/include/petsc4py
  copying src/PETSc.pxd -> build/lib.linux-x86_64-3.8/petsc4py
  copying src/lib/petsc.cfg -> build/lib.linux-x86_64-3.8/petsc4py/lib
  running build_ext
  error: PETSc not found
  ----------------------------------------
  ERROR: Failed building wheel for petsc4py
  Running setup.py clean for petsc4py
  Building wheel for petsc (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/ygandhi/paralleltopologyoptimization/plexus/build/Linux-x86_64/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-m5ldeeqw/petsc/setup.py'"'"'; __file__='"'"'/tmp/pip-install-m5ldeeqw/petsc/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-_jwwfujp
       cwd: /tmp/pip-install-m5ldeeqw/petsc/
  Complete output (1 lines):
  petsc: this package cannot be built as a wheel
  ----------------------------------------
  ERROR: Failed building wheel for petsc
  Running setup.py clean for petsc
Failed to build petsc4py petsc

I have searched around online for quite a while now and have found a few related solutions, but they didn't work for me. https://bitbucket.org/petsc/petsc4py/issues/132/attributeerror-module-petsc-has-no

Would you mind advising on how to resolve this issue of building wheel for petsc and petsc4py?

I wait for your positive response. Thanks!

Edited by Barry Smith