使用 pip 与 Anaconda 一起安装 petsc4py,以指示外部 PETSc 目录

Issue installing petsc4py with Anaconda using pip, to indicate external PETSc directory

一)问题

我无法使用 pip 在我的 Anaconda 环境中安装 petsc4py

使用 conda 安装不起作用,因为它不会在安装期间检查我预定义的 PETSC_DIR 和 PETSC_ARCH 环境变量。 numpycython 已安装。

pip install 的错误输出显示在下面的 IV 部分。

II) 版本

我有 Ananconda 2020.02,安装了 Python 3.7。我的 OS 是 Ubuntu 18.04.

III) 重现问题

1) 进行 OpenMPI 4.0.3

的用户安装

配置使用

--prefix="/home/$USER/.openmpi" CC=gcc FC=gfortran

然后makemake install

.openmpi/bin文件添加到PATH并将.openmpi/lib添加到LD_LIBRARY_PATH:

export PATH=/home/$USER/.openmpi/bin:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/$USER/.openmpi/lib/

2) 安装PETSc 3.13

配置从/home/$USER/.openmpi/bin指示mpiccmpifort并下载blas/lapack、scalapack、MUMPS、METIS、PARMETIS和PTSCOTCH,使用-O2编译器优化(注意:我将 MKL 用于 blas/lapack 和 scalapack)。还要在 ./configure 中指明 PETSC_DIR 文件夹位置和 PETSC_ARCH 名称。我选择了无 C++ 编译器选项。

然后 make allmake check。我也做了一个make test,花了好一段时间。没有失败,只有成功,跳过,做。

export PETSC_DIRPETSC_ARCH(对 pets4py 很重要)。

3) 使用 pip

安装 mpi4py

我使用 pip 安装了这个,因为根据 Iliev 在 .

4) 尝试使用 pip

安装 petsc4py

我使用 --no-cache-dir 编写:

pip install --no-cache-dir petsc4py

构建失败。终端中显示的信息在下一节中显示。

四)错误

错误如下所示。

(奖金元问题:有没有办法在 Stack Overflow 的代码围栏中设置自动换行符?)

Collecting petsc4py
  Downloading petsc4py-3.12.0.tar.gz (1.8 MB)
     |████████████████████████████████| 1.8 MB 2.8 MB/s 
Requirement already satisfied: numpy in ./anaconda3/lib/python3.7/site-packages (from petsc4py) (1.18.1)
Building wheels for collected packages: petsc4py
  Building wheel for petsc4py (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/breno/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-5qdqmoex/petsc4py/setup.py'"'"'; __file__='"'"'/tmp/pip-install-5qdqmoex/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-khk8pv9d
       cwd: /tmp/pip-install-5qdqmoex/petsc4py/
  Complete output (97 lines):
  running bdist_wheel
  running build
  running build_src
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.7
  creating build/lib.linux-x86_64-3.7/petsc4py
  copying src/PETSc.py -> build/lib.linux-x86_64-3.7/petsc4py
  copying src/__init__.py -> build/lib.linux-x86_64-3.7/petsc4py
  copying src/__main__.py -> build/lib.linux-x86_64-3.7/petsc4py
  creating build/lib.linux-x86_64-3.7/petsc4py/lib
  copying src/lib/__init__.py -> build/lib.linux-x86_64-3.7/petsc4py/lib
  creating build/lib.linux-x86_64-3.7/petsc4py/include
  creating build/lib.linux-x86_64-3.7/petsc4py/include/petsc4py
  copying src/include/petsc4py/petsc4py.PETSc_api.h -> build/lib.linux-x86_64-3.7/petsc4py/include/petsc4py
  copying src/include/petsc4py/petsc4py.h -> build/lib.linux-x86_64-3.7/petsc4py/include/petsc4py
  copying src/include/petsc4py/petsc4py.PETSc.h -> build/lib.linux-x86_64-3.7/petsc4py/include/petsc4py
  copying src/include/petsc4py/numpy.h -> build/lib.linux-x86_64-3.7/petsc4py/include/petsc4py
  copying src/include/petsc4py/petsc4py.i -> build/lib.linux-x86_64-3.7/petsc4py/include/petsc4py
  copying src/include/petsc4py/PETSc.pxd -> build/lib.linux-x86_64-3.7/petsc4py/include/petsc4py
  copying src/include/petsc4py/__init__.pxd -> build/lib.linux-x86_64-3.7/petsc4py/include/petsc4py
  copying src/include/petsc4py/__init__.pyx -> build/lib.linux-x86_64-3.7/petsc4py/include/petsc4py
  copying src/PETSc.pxd -> build/lib.linux-x86_64-3.7/petsc4py
  copying src/lib/petsc.cfg -> build/lib.linux-x86_64-3.7/petsc4py/lib
  running build_ext
  PETSC_DIR:    /home/breno/Documents/petsc
  PETSC_ARCH:   MUMPS-mkl-real-opt
  version:      3.13.0 release
  integer-size: 32-bit
  scalar-type:  real
  precision:    double
  language:     CONLY
  compiler:     /home/breno/.openmpi/bin/mpicc
  linker:       /home/breno/.openmpi/bin/mpicc
  building 'PETSc' extension
  creating build/temp.linux-x86_64-3.7
  creating build/temp.linux-x86_64-3.7/MUMPS-mkl-real-opt
  creating build/temp.linux-x86_64-3.7/MUMPS-mkl-real-opt/src
  /home/breno/.openmpi/bin/mpicc -pthread -B /home/breno/anaconda3/compiler_compat -Wl,--sysroot=/ -fPIC -Wall -Wwrite-strings -Wno-strict-aliasing -Wno-unknown-pragmas -fstack-protector -O2 -march=native -mtune=native -fPIC -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -I/home/breno/Documents/petsc/MUMPS-mkl-real-opt/include -I/home/breno/Documents/petsc/include -Isrc/include -I/home/breno/anaconda3/lib/python3.7/site-packages/numpy/core/include -I/home/breno/anaconda3/include/python3.7m -c src/PETSc.c -o build/temp.linux-x86_64-3.7/MUMPS-mkl-real-opt/src/PETSc.o
  In file included from src/PETSc.c:4:0:
  src/petsc4py.PETSc.c: In function ‘__pyx_pf_8petsc4py_5PETSc_3Sys_28infoAllow’:
  src/petsc4py.PETSc.c:65427:47: error: too many arguments to function ‘PetscInfoAllow’
     __pyx_t_2 = __pyx_f_8petsc4py_5PETSc_CHKERR(PetscInfoAllow(__pyx_v_tval, NULL)); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(27, 163, __pyx_L1_error)
                                                 ^~~~~~~~~~~~~~
  In file included from /home/breno/Documents/petsc/include/petscsys.h:1474:0,
                   from /home/breno/Documents/petsc/include/petscbag.h:4,
                   from /home/breno/Documents/petsc/include/petsc.h:5,
                   from src/petsc4py.PETSc.c:596,
                   from src/PETSc.c:4:
  /home/breno/Documents/petsc/include/petsclog.h:56:29: note: declared here
   PETSC_EXTERN PetscErrorCode PetscInfoAllow(PetscBool);
                               ^~~~~~~~~~~~~~
  In file included from src/PETSc.c:4:0:
  src/petsc4py.PETSc.c: In function ‘__pyx_pf_8petsc4py_5PETSc_3Mat_304matMultSymbolic’:
  src/petsc4py.PETSc.c:148044:47: warning: implicit declaration of function ‘MatMatMultSymbolic’; did you mean ‘MatProductSymbolic’? [-Wimplicit-function-declaration]
     __pyx_t_5 = __pyx_f_8petsc4py_5PETSc_CHKERR(MatMatMultSymbolic(__pyx_v_self->mat, __pyx_v_mat->mat, __pyx_v_rval, (&__pyx_v_result->mat))); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(36, 1309, __pyx_L1_error)
                                                 ^~~~~~~~~~~~~~~~~~
                                                 MatProductSymbolic
  src/petsc4py.PETSc.c: In function ‘__pyx_pf_8petsc4py_5PETSc_3Mat_306matMultNumeric’:
  src/petsc4py.PETSc.c:148235:47: warning: implicit declaration of function ‘MatMatMultNumeric’; did you mean ‘MatProductNumeric’? [-Wimplicit-function-declaration]
     __pyx_t_4 = __pyx_f_8petsc4py_5PETSc_CHKERR(MatMatMultNumeric(__pyx_v_self->mat, __pyx_v_mat->mat, __pyx_v_result->mat)); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(36, 1317, __pyx_L1_error)
                                                 ^~~~~~~~~~~~~~~~~
                                                 MatProductNumeric
  src/petsc4py.PETSc.c: In function ‘__pyx_pf_8petsc4py_5PETSc_6DMStag_54get1DCoordinateLocationSlot’:
  src/petsc4py.PETSc.c:265960:3: warning: ‘DMStagGet1dCoordinateLocationSlot’ is deprecated [-Wdeprecated-declarations]
     __pyx_t_2 = __pyx_f_8petsc4py_5PETSc_CHKERR(DMStagGet1dCoordinateLocationSlot(__pyx_v_self->__pyx_base.dm, __pyx_v_sloc, (&__pyx_v_slot))); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(47, 274, __pyx_L1_error)
     ^~~~~~~~~
  In file included from /home/breno/Documents/petsc/include/petsc.h:22:0,
                   from src/petsc4py.PETSc.c:596,
                   from src/PETSc.c:4:
  /home/breno/Documents/petsc/include/petscdmstag.h:127:130: note: declared here
   PETSC_DEPRECATED_FUNCTION("Use DMStagGetProductCoordinateLocationSlot() (since version 3.13") PETSC_STATIC_INLINE PetscErrorCode DMStagGet1dCoordinateLocationSlot(DM dm,DMStagStencilLocation loc,PetscInt *s) {return DMStagGetProductCoordinateLocationSlot(dm,loc,s);}
                                                                                                                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  In file included from src/PETSc.c:4:0:
  src/petsc4py.PETSc.c: In function ‘__pyx_pymod_exec_PETSc’:
  src/petsc4py.PETSc.c:309773:43: error: ‘MATLMVMBRDN’ undeclared (first use in this function); did you mean ‘MATLMVMBROYDEN’?
     __pyx_t_7 = __pyx_f_8petsc4py_5PETSc_S_(MATLMVMBRDN); if (unlikely(!__pyx_t_7)) __PYX_ERR(36, 78, __pyx_L1_error)
                                             ^~~~~~~~~~~
                                             MATLMVMBROYDEN
  src/petsc4py.PETSc.c:309773:43: note: each undeclared identifier is reported only once for each function it appears in
  src/petsc4py.PETSc.c:309785:43: error: ‘MATLMVMBADBRDN’ undeclared (first use in this function); did you mean ‘MATLMVMBRDN’?
     __pyx_t_7 = __pyx_f_8petsc4py_5PETSc_S_(MATLMVMBADBRDN); if (unlikely(!__pyx_t_7)) __PYX_ERR(36, 79, __pyx_L1_error)
                                             ^~~~~~~~~~~~~~
                                             MATLMVMBRDN
  src/petsc4py.PETSc.c:309797:43: error: ‘MATLMVMSYMBRDN’ undeclared (first use in this function); did you mean ‘MATLMVMBADBRDN’?
     __pyx_t_7 = __pyx_f_8petsc4py_5PETSc_S_(MATLMVMSYMBRDN); if (unlikely(!__pyx_t_7)) __PYX_ERR(36, 80, __pyx_L1_error)
                                             ^~~~~~~~~~~~~~
                                             MATLMVMBADBRDN
  src/petsc4py.PETSc.c:309809:43: error: ‘MATLMVMSYMBADBRDN’ undeclared (first use in this function); did you mean ‘MATLMVMSYMBRDN’?
     __pyx_t_7 = __pyx_f_8petsc4py_5PETSc_S_(MATLMVMSYMBADBRDN); if (unlikely(!__pyx_t_7)) __PYX_ERR(36, 81, __pyx_L1_error)
                                             ^~~~~~~~~~~~~~~~~
                                             MATLMVMSYMBRDN
  src/petsc4py.PETSc.c:309821:43: error: ‘MATLMVMDIAGBRDN’ undeclared (first use in this function); did you mean ‘MATLMVMBADBRDN’?
     __pyx_t_7 = __pyx_f_8petsc4py_5PETSc_S_(MATLMVMDIAGBRDN); if (unlikely(!__pyx_t_7)) __PYX_ERR(36, 82, __pyx_L1_error)
                                             ^~~~~~~~~~~~~~~
                                             MATLMVMBADBRDN
  error: command '/home/breno/.openmpi/bin/mpicc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for petsc4py
  Running setup.py clean for petsc4py
Failed to build petsc4py
Installing collected packages: petsc4py
    Running setup.py install for petsc4py ... error
    ERROR: Command errored out with exit status 1:
     command: /home/breno/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-5qdqmoex/petsc4py/setup.py'"'"'; __file__='"'"'/tmp/pip-install-5qdqmoex/petsc4py/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-_npojm20/install-record.txt --single-version-externally-managed --compile --install-headers /home/breno/anaconda3/include/python3.7m/petsc4py
         cwd: /tmp/pip-install-5qdqmoex/petsc4py/
    Complete output (97 lines):
    running install
    running build
    running build_src
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.7
    creating build/lib.linux-x86_64-3.7/petsc4py
    copying src/PETSc.py -> build/lib.linux-x86_64-3.7/petsc4py
    copying src/__init__.py -> build/lib.linux-x86_64-3.7/petsc4py
    copying src/__main__.py -> build/lib.linux-x86_64-3.7/petsc4py
    creating build/lib.linux-x86_64-3.7/petsc4py/lib
    copying src/lib/__init__.py -> build/lib.linux-x86_64-3.7/petsc4py/lib
    creating build/lib.linux-x86_64-3.7/petsc4py/include
    creating build/lib.linux-x86_64-3.7/petsc4py/include/petsc4py
    copying src/include/petsc4py/petsc4py.PETSc_api.h -> build/lib.linux-x86_64-3.7/petsc4py/include/petsc4py
    copying src/include/petsc4py/petsc4py.h -> build/lib.linux-x86_64-3.7/petsc4py/include/petsc4py
    copying src/include/petsc4py/petsc4py.PETSc.h -> build/lib.linux-x86_64-3.7/petsc4py/include/petsc4py
    copying src/include/petsc4py/numpy.h -> build/lib.linux-x86_64-3.7/petsc4py/include/petsc4py
    copying src/include/petsc4py/petsc4py.i -> build/lib.linux-x86_64-3.7/petsc4py/include/petsc4py
    copying src/include/petsc4py/PETSc.pxd -> build/lib.linux-x86_64-3.7/petsc4py/include/petsc4py
    copying src/include/petsc4py/__init__.pxd -> build/lib.linux-x86_64-3.7/petsc4py/include/petsc4py
    copying src/include/petsc4py/__init__.pyx -> build/lib.linux-x86_64-3.7/petsc4py/include/petsc4py
    copying src/PETSc.pxd -> build/lib.linux-x86_64-3.7/petsc4py
    copying src/lib/petsc.cfg -> build/lib.linux-x86_64-3.7/petsc4py/lib
    running build_ext
    PETSC_DIR:    /home/breno/Documents/petsc
    PETSC_ARCH:   MUMPS-mkl-real-opt
    version:      3.13.0 release
    integer-size: 32-bit
    scalar-type:  real
    precision:    double
    language:     CONLY
    compiler:     /home/breno/.openmpi/bin/mpicc
    linker:       /home/breno/.openmpi/bin/mpicc
    building 'PETSc' extension
    creating build/temp.linux-x86_64-3.7
    creating build/temp.linux-x86_64-3.7/MUMPS-mkl-real-opt
    creating build/temp.linux-x86_64-3.7/MUMPS-mkl-real-opt/src
    /home/breno/.openmpi/bin/mpicc -pthread -B /home/breno/anaconda3/compiler_compat -Wl,--sysroot=/ -fPIC -Wall -Wwrite-strings -Wno-strict-aliasing -Wno-unknown-pragmas -fstack-protector -O2 -march=native -mtune=native -fPIC -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -I/home/breno/Documents/petsc/MUMPS-mkl-real-opt/include -I/home/breno/Documents/petsc/include -Isrc/include -I/home/breno/anaconda3/lib/python3.7/site-packages/numpy/core/include -I/home/breno/anaconda3/include/python3.7m -c src/PETSc.c -o build/temp.linux-x86_64-3.7/MUMPS-mkl-real-opt/src/PETSc.o
    In file included from src/PETSc.c:4:0:
    src/petsc4py.PETSc.c: In function ‘__pyx_pf_8petsc4py_5PETSc_3Sys_28infoAllow’:
    src/petsc4py.PETSc.c:65427:47: error: too many arguments to function ‘PetscInfoAllow’
       __pyx_t_2 = __pyx_f_8petsc4py_5PETSc_CHKERR(PetscInfoAllow(__pyx_v_tval, NULL)); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(27, 163, __pyx_L1_error)
                                                   ^~~~~~~~~~~~~~
    In file included from /home/breno/Documents/petsc/include/petscsys.h:1474:0,
                     from /home/breno/Documents/petsc/include/petscbag.h:4,
                     from /home/breno/Documents/petsc/include/petsc.h:5,
                     from src/petsc4py.PETSc.c:596,
                     from src/PETSc.c:4:
    /home/breno/Documents/petsc/include/petsclog.h:56:29: note: declared here
     PETSC_EXTERN PetscErrorCode PetscInfoAllow(PetscBool);
                                 ^~~~~~~~~~~~~~
    In file included from src/PETSc.c:4:0:
    src/petsc4py.PETSc.c: In function ‘__pyx_pf_8petsc4py_5PETSc_3Mat_304matMultSymbolic’:
    src/petsc4py.PETSc.c:148044:47: warning: implicit declaration of function ‘MatMatMultSymbolic’; did you mean ‘MatProductSymbolic’? [-Wimplicit-function-declaration]
       __pyx_t_5 = __pyx_f_8petsc4py_5PETSc_CHKERR(MatMatMultSymbolic(__pyx_v_self->mat, __pyx_v_mat->mat, __pyx_v_rval, (&__pyx_v_result->mat))); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(36, 1309, __pyx_L1_error)
                                                   ^~~~~~~~~~~~~~~~~~
                                                   MatProductSymbolic
    src/petsc4py.PETSc.c: In function ‘__pyx_pf_8petsc4py_5PETSc_3Mat_306matMultNumeric’:
    src/petsc4py.PETSc.c:148235:47: warning: implicit declaration of function ‘MatMatMultNumeric’; did you mean ‘MatProductNumeric’? [-Wimplicit-function-declaration]
       __pyx_t_4 = __pyx_f_8petsc4py_5PETSc_CHKERR(MatMatMultNumeric(__pyx_v_self->mat, __pyx_v_mat->mat, __pyx_v_result->mat)); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(36, 1317, __pyx_L1_error)
                                                   ^~~~~~~~~~~~~~~~~
                                                   MatProductNumeric
    src/petsc4py.PETSc.c: In function ‘__pyx_pf_8petsc4py_5PETSc_6DMStag_54get1DCoordinateLocationSlot’:
    src/petsc4py.PETSc.c:265960:3: warning: ‘DMStagGet1dCoordinateLocationSlot’ is deprecated [-Wdeprecated-declarations]
       __pyx_t_2 = __pyx_f_8petsc4py_5PETSc_CHKERR(DMStagGet1dCoordinateLocationSlot(__pyx_v_self->__pyx_base.dm, __pyx_v_sloc, (&__pyx_v_slot))); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(47, 274, __pyx_L1_error)
       ^~~~~~~~~
    In file included from /home/breno/Documents/petsc/include/petsc.h:22:0,
                     from src/petsc4py.PETSc.c:596,
                     from src/PETSc.c:4:
    /home/breno/Documents/petsc/include/petscdmstag.h:127:130: note: declared here
     PETSC_DEPRECATED_FUNCTION("Use DMStagGetProductCoordinateLocationSlot() (since version 3.13") PETSC_STATIC_INLINE PetscErrorCode DMStagGet1dCoordinateLocationSlot(DM dm,DMStagStencilLocation loc,PetscInt *s) {return DMStagGetProductCoordinateLocationSlot(dm,loc,s);}
                                                                                                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from src/PETSc.c:4:0:
    src/petsc4py.PETSc.c: In function ‘__pyx_pymod_exec_PETSc’:
    src/petsc4py.PETSc.c:309773:43: error: ‘MATLMVMBRDN’ undeclared (first use in this function); did you mean ‘MATLMVMBROYDEN’?
       __pyx_t_7 = __pyx_f_8petsc4py_5PETSc_S_(MATLMVMBRDN); if (unlikely(!__pyx_t_7)) __PYX_ERR(36, 78, __pyx_L1_error)
                                               ^~~~~~~~~~~
                                               MATLMVMBROYDEN
    src/petsc4py.PETSc.c:309773:43: note: each undeclared identifier is reported only once for each function it appears in
    src/petsc4py.PETSc.c:309785:43: error: ‘MATLMVMBADBRDN’ undeclared (first use in this function); did you mean ‘MATLMVMBRDN’?
       __pyx_t_7 = __pyx_f_8petsc4py_5PETSc_S_(MATLMVMBADBRDN); if (unlikely(!__pyx_t_7)) __PYX_ERR(36, 79, __pyx_L1_error)
                                               ^~~~~~~~~~~~~~
                                               MATLMVMBRDN
    src/petsc4py.PETSc.c:309797:43: error: ‘MATLMVMSYMBRDN’ undeclared (first use in this function); did you mean ‘MATLMVMBADBRDN’?
       __pyx_t_7 = __pyx_f_8petsc4py_5PETSc_S_(MATLMVMSYMBRDN); if (unlikely(!__pyx_t_7)) __PYX_ERR(36, 80, __pyx_L1_error)
                                               ^~~~~~~~~~~~~~
                                               MATLMVMBADBRDN
    src/petsc4py.PETSc.c:309809:43: error: ‘MATLMVMSYMBADBRDN’ undeclared (first use in this function); did you mean ‘MATLMVMSYMBRDN’?
       __pyx_t_7 = __pyx_f_8petsc4py_5PETSc_S_(MATLMVMSYMBADBRDN); if (unlikely(!__pyx_t_7)) __PYX_ERR(36, 81, __pyx_L1_error)
                                               ^~~~~~~~~~~~~~~~~
                                               MATLMVMSYMBRDN
    src/petsc4py.PETSc.c:309821:43: error: ‘MATLMVMDIAGBRDN’ undeclared (first use in this function); did you mean ‘MATLMVMBADBRDN’?
       __pyx_t_7 = __pyx_f_8petsc4py_5PETSc_S_(MATLMVMDIAGBRDN); if (unlikely(!__pyx_t_7)) __PYX_ERR(36, 82, __pyx_L1_error)
                                               ^~~~~~~~~~~~~~~
                                               MATLMVMBADBRDN
    error: command '/home/breno/.openmpi/bin/mpicc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/breno/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-5qdqmoex/petsc4py/setup.py'"'"'; __file__='"'"'/tmp/pip-install-5qdqmoex/petsc4py/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-_npojm20/install-record.txt --single-version-externally-managed --compile --install-headers /home/breno/anaconda3/include/python3.7m/petsc4py Check the logs for full command output.

我试图用当时最新发布的版本 3.12.0 安装 petsc4py,同时安装和配置了 PETSc 版本 3.13.0now 似乎很明显它不会起作用,但在 documentation.

中没有明确提及这一点

您可以使用pip install https://bitbucket.org/petsc/petsc4py/issues/137/error-installing-in-anaconda-environment安装none发布的版本,或者等待它正式发布!

重要结论

确保您的 PETSc 版本与 petsc4py 相同!