首页 > 解决方案 > 在 Red Hat Linux 上安装 cvxpy 的问题

问题描述

我尝试在 Linux 上使用pip install --user cvxpy. 它给了我在为 qdldl (setup.py) 构建轮子中出现 g++ 错误的问题:/tmp/pip-install-1k_mttks/qdldl/c/build/out/linqdldlamd.a: No such file or directory

如何解决?是因为我无权安装造成的吗?

[xxx@xxx ~]$ module load python/3.6.8
[xxx@xxx ~]$ module load cmake/3.12.4
[xxx@xxx ~]$ pip install --user cvxpy
Collecting cvxpy
Requirement already satisfied: ecos>=2 in ./.local/lib/python3.6/site-packages (from cvxpy) (2.0.7.post1)
Requirement already satisfied: scs>=1.1.6 in ./.local/lib/python3.6/site-packages (from cvxpy) (2.1.4)
Collecting osqp>=0.4.1 (from cvxpy)
  Using cached https://files.pythonhosted.org/packages/76/82/b0693a167e4b9b5e94f4988f6df3d7866e9e41a316a58f1053dd21370f1a/osqp-0.6.2.post0-cp36-cp36m-manylinux1_x86_64.whl
Requirement already satisfied: scipy>=1.1.0 in /ddn/apps/Cluster-Apps/python/3.6.8/lib/python3.6/site-packages (from cvxpy) (1.2.1)
Requirement already satisfied: numpy>=1.15 in /ddn/apps/Cluster-Apps/python/3.6.8/lib/python3.6/site-packages (from cvxpy) (1.16.1)
Collecting qdldl (from osqp>=0.4.1->cvxpy)
  Using cached https://files.pythonhosted.org/packages/ec/a3/db0e7c9fec5387dc33cbd2819329c141ba76497148aa9fab4bd1a7c2a279/qdldl-0.1.5.post0.tar.gz
Building wheels for collected packages: qdldl
  Building wheel for qdldl (setup.py) ... error
  ERROR: Complete output from command /ddn/apps/Cluster-Apps/python/3.6.8/bin/python3.6 -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-lf6hzztm/qdldl/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-y1vx5vdf --python-tag cp36:
  ERROR: running bdist_wheel
  running build
  running build_ext
  -- The C compiler identification is GNU 4.8.5
  -- The CXX compiler identification is GNU 4.8.5
  -- Check for working C compiler: /usr/bin/cc
  -- Check for working C compiler: /usr/bin/cc -- works
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- Check for working CXX compiler: /usr/bin/c++
  -- Check for working CXX compiler: /usr/bin/c++ -- works
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Floats are OFF
  -- Long integers (64bit) are ON
  -- Configuring done
  -- Generating done
  -- Build files have been written to: /tmp/pip-install-lf6hzztm/qdldl/c/build
  Scanning dependencies of target qdldlobject
  [  6%] Building C object qdldl/CMakeFiles/qdldlobject.dir/src/qdldl.c.o
  [  6%] Built target qdldlobject
  Scanning dependencies of target qdldlamd
  [ 13%] Building C object CMakeFiles/qdldlamd.dir/amd/src/amd_1.c.o
  [ 20%] Building C object CMakeFiles/qdldlamd.dir/amd/src/amd_2.c.o
  [ 26%] Building C object CMakeFiles/qdldlamd.dir/amd/src/amd_aat.c.o
  [ 33%] Building C object CMakeFiles/qdldlamd.dir/amd/src/amd_control.c.o
  [ 40%] Building C object CMakeFiles/qdldlamd.dir/amd/src/amd_defaults.c.o
  [ 46%] Building C object CMakeFiles/qdldlamd.dir/amd/src/amd_info.c.o
  [ 53%] Building C object CMakeFiles/qdldlamd.dir/amd/src/amd_order.c.o
  [ 60%] Building C object CMakeFiles/qdldlamd.dir/amd/src/amd_post_tree.c.o
  [ 66%] Building C object CMakeFiles/qdldlamd.dir/amd/src/amd_postorder.c.o
  [ 73%] Building C object CMakeFiles/qdldlamd.dir/amd/src/amd_preprocess.c.o
  [ 80%] Building C object CMakeFiles/qdldlamd.dir/amd/src/amd_valid.c.o
  [ 86%] Building C object CMakeFiles/qdldlamd.dir/amd/src/SuiteSparse_config.c.o
  [ 93%] Building C object CMakeFiles/qdldlamd.dir/amd/src/perm.c.o
  /tmp/pip-install-lf6hzztm/qdldl/c/amd/src/perm.c: In function 'permute_x':
  /tmp/pip-install-lf6hzztm/qdldl/c/amd/src/perm.c:23:5: error: 'for' loop initial declarations are only allowed in C99 mode
       for (QDLDL_int j = 0 ; j < n ; j++) x[j] = b[P[j]];
       ^
  /tmp/pip-install-lf6hzztm/qdldl/c/amd/src/perm.c:23:5: note: use option -std=c99 or -std=gnu99 to compile your code
  /tmp/pip-install-lf6hzztm/qdldl/c/amd/src/perm.c: In function 'permutet_x':
  /tmp/pip-install-lf6hzztm/qdldl/c/amd/src/perm.c:28:5: error: 'for' loop initial declarations are only allowed in C99 mode
       for (QDLDL_int j = 0 ; j < n ; j++) x[P[j]] = b[j];
       ^
  /tmp/pip-install-lf6hzztm/qdldl/c/amd/src/perm.c: In function 'pinv':
  /tmp/pip-install-lf6hzztm/qdldl/c/amd/src/perm.c:33:3: error: 'for' loop initial declarations are only allowed in C99 mode
     for (QDLDL_int k = 0; k < n; k++) pinv[p[k]] = k;  /* invert the permutation */
     ^
  /tmp/pip-install-lf6hzztm/qdldl/c/amd/src/perm.c: In function 'update_A':
  /tmp/pip-install-lf6hzztm/qdldl/c/amd/src/perm.c:88:3: error: 'for' loop initial declarations are only allowed in C99 mode
     for (QDLDL_int i = 0; i < Anz; i++) Apermx[AtoAperm[i]] = Anewx[i];
     ^
  gmake[3]: *** [CMakeFiles/qdldlamd.dir/amd/src/perm.c.o] Error 1
  gmake[2]: *** [CMakeFiles/qdldlamd.dir/all] Error 2
  gmake[1]: *** [CMakeFiles/qdldlamd.dir/rule] Error 2
  gmake: *** [qdldlamd] Error 2
  building 'qdldl' extension
  creating build
  creating build/temp.linux-x86_64-3.6
  creating build/temp.linux-x86_64-3.6/cpp
  gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Ic -Ic/qdldl/include -I/ddn/home/cfzh32/.local/lib/python3.6/site-packages/pybind11/include -I/ddn/home/cfzh32/.local/lib/python3.6/site-packages/pybind11/include -I/usr/local/Cluster-Apps/python/3.6.8/include/python3.6m -c cpp/wrapper.cpp -o build/temp.linux-x86_64-3.6/cpp/wrapper.o -O3 -std=c++11
  gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Ic -Ic/qdldl/include -I/ddn/home/cfzh32/.local/lib/python3.6/site-packages/pybind11/include -I/ddn/home/cfzh32/.local/lib/python3.6/site-packages/pybind11/include -I/usr/local/Cluster-Apps/python/3.6.8/include/python3.6m -c cpp/qdldl.cpp -o build/temp.linux-x86_64-3.6/cpp/qdldl.o -O3 -std=c++11
  creating build/lib.linux-x86_64-3.6
  g++ -pthread -shared build/temp.linux-x86_64-3.6/cpp/wrapper.o build/temp.linux-x86_64-3.6/cpp/qdldl.o /tmp/pip-install-lf6hzztm/qdldl/c/build/out/libqdldlamd.a -L/ddn/apps/Cluster-Apps/python/3.6.8/lib -lpython3.6m -o build/lib.linux-x86_64-3.6/qdldl.cpython-36m-x86_64-linux-gnu.so
  g++: error: /tmp/pip-install-lf6hzztm/qdldl/c/build/out/libqdldlamd.a: No such file or directory
  error: command 'g++' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for qdldl
  Running setup.py clean for qdldl
Failed to build qdldl
Installing collected packages: qdldl, osqp, cvxpy
  Running setup.py install for qdldl ... error
    ERROR: Complete output from command /ddn/apps/Cluster-Apps/python/3.6.8/bin/python3.6 -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-lf6hzztm/qdldl/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-c4w40mrn/install-record.txt --single-version-externally-managed --compile --user --prefix=:
    ERROR: running install
    running build
    running build_ext
    -- Floats are OFF
    -- Long integers (64bit) are ON
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /tmp/pip-install-lf6hzztm/qdldl/c/build
    [  6%] Built target qdldlobject
    [ 13%] Building C object CMakeFiles/qdldlamd.dir/amd/src/perm.c.o
    /tmp/pip-install-lf6hzztm/qdldl/c/amd/src/perm.c: In function 'permute_x':
    /tmp/pip-install-lf6hzztm/qdldl/c/amd/src/perm.c:23:5: error: 'for' loop initial declarations are only allowed in C99 mode
         for (QDLDL_int j = 0 ; j < n ; j++) x[j] = b[P[j]];
         ^
    /tmp/pip-install-lf6hzztm/qdldl/c/amd/src/perm.c:23:5: note: use option -std=c99 or -std=gnu99 to compile your code
    /tmp/pip-install-lf6hzztm/qdldl/c/amd/src/perm.c: In function 'permutet_x':
    /tmp/pip-install-lf6hzztm/qdldl/c/amd/src/perm.c:28:5: error: 'for' loop initial declarations are only allowed in C99 mode
         for (QDLDL_int j = 0 ; j < n ; j++) x[P[j]] = b[j];
         ^
    /tmp/pip-install-lf6hzztm/qdldl/c/amd/src/perm.c: In function 'pinv':
    /tmp/pip-install-lf6hzztm/qdldl/c/amd/src/perm.c:33:3: error: 'for' loop initial declarations are only allowed in C99 mode
       for (QDLDL_int k = 0; k < n; k++) pinv[p[k]] = k;  /* invert the permutation */
       ^
    /tmp/pip-install-lf6hzztm/qdldl/c/amd/src/perm.c: In function 'update_A':
    /tmp/pip-install-lf6hzztm/qdldl/c/amd/src/perm.c:88:3: error: 'for' loop initial declarations are only allowed in C99 mode
       for (QDLDL_int i = 0; i < Anz; i++) Apermx[AtoAperm[i]] = Anewx[i];
       ^
    gmake[3]: *** [CMakeFiles/qdldlamd.dir/amd/src/perm.c.o] Error 1
    gmake[2]: *** [CMakeFiles/qdldlamd.dir/all] Error 2
    gmake[1]: *** [CMakeFiles/qdldlamd.dir/rule] Error 2
    gmake: *** [qdldlamd] Error 2
    building 'qdldl' extension
    creating build
    creating build/temp.linux-x86_64-3.6
    creating build/temp.linux-x86_64-3.6/cpp
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Ic -Ic/qdldl/include -I/ddn/home/cfzh32/.local/lib/python3.6/site-packages/pybind11/include -I/ddn/home/cfzh32/.local/lib/python3.6/site-packages/pybind11/include -I/usr/local/Cluster-Apps/python/3.6.8/include/python3.6m -c cpp/wrapper.cpp -o build/temp.linux-x86_64-3.6/cpp/wrapper.o -O3 -std=c++11
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Ic -Ic/qdldl/include -I/ddn/home/cfzh32/.local/lib/python3.6/site-packages/pybind11/include -I/ddn/home/cfzh32/.local/lib/python3.6/site-packages/pybind11/include -I/usr/local/Cluster-Apps/python/3.6.8/include/python3.6m -c cpp/qdldl.cpp -o build/temp.linux-x86_64-3.6/cpp/qdldl.o -O3 -std=c++11
    creating build/lib.linux-x86_64-3.6
    g++ -pthread -shared build/temp.linux-x86_64-3.6/cpp/wrapper.o build/temp.linux-x86_64-3.6/cpp/qdldl.o /tmp/pip-install-lf6hzztm/qdldl/c/build/out/libqdldlamd.a -L/ddn/apps/Cluster-Apps/python/3.6.8/lib -lpython3.6m -o build/lib.linux-x86_64-3.6/qdldl.cpython-36m-x86_64-linux-gnu.so
    g++: error: /tmp/pip-install-lf6hzztm/qdldl/c/build/out/libqdldlamd.a: No such file or directory
    error: command 'g++' failed with exit status 1
    ----------------------------------------
ERROR: Command "/ddn/apps/Cluster-Apps/python/3.6.8/bin/python3.6 -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-lf6hzztm/qdldl/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-c4w40mrn/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-install-lf6hzztm/qdldl/
WARNING: You are using pip version 19.1.1, however version 21.2.4 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

标签: pythonlinuxcvxpy

解决方案


推荐阅读