【问题标题】:How to install GLPK for CVXPY on Windows 10?如何在 Windows 10 上为 CVXPY 安装 GLPK?
【发布时间】:2019-04-02 21:39:42
【问题描述】:

我正在尝试安装 GLPK 求解器以在 Python 中使用。按照 CVXPY 网站上的instructions,我尝试了pip install cvxpy[glpk],但收到以下错误消息:

cvxpy 1.0.21 不提供额外的“glpk”

发生了什么事?如何为 cvxpy 安装 GLPK_MI 求解器?

【问题讨论】:

    标签: windows pip glpk cvxpy


    【解决方案1】:

    cvxpy 1.0.21 was released 2019 年 3 月 8 日,26 天前。 glpk extra was added 2019 年 3 月 10 日,24 天前。

    额外的在 git 存储库中可用,但尚未发布到 PyPI。您可以尝试从 git repo 安装它:

    pip install 'git+https://github.com/cvxgrp/cvxpy.git#egg=cvxpy[glpk]'
    

    为我工作:

    $ pip install 'git+https://github.com/cvxgrp/cvxpy.git#egg=cvxpy[glpk]'
    Collecting cvxpy[glpk] from git+https://github.com/cvxgrp/cvxpy.git#egg=cvxpy[glpk]
      Cloning https://github.com/cvxgrp/cvxpy.git to /tmp/pip-install-u_k0fsp4/cvxpy
    Collecting osqp>=0.4.1 (from cvxpy[glpk])
      Downloading https://files.pythonhosted.org/packages/ac/34/1edd8da520354be1e280fb62afe1c26447b172bbce2c56934d57c0bfa23f/osqp-0.5.0-cp35-cp35m-manylinux1_i686.whl (143kB)
        100% |################################| 153kB 2.6MB/s 
    Collecting ecos>=2 (from cvxpy[glpk])
      Downloading https://files.pythonhosted.org/packages/6e/14/fa2c1c398a4a85465f2817e8f6c9220bb395d058a32583e903dbe706aaea/ecos-2.0.7.post1-cp35-cp35m-manylinux1_i686.whl (134kB)
        100% |################################| 143kB 11.9MB/s 
    Collecting scs>=1.1.3 (from cvxpy[glpk])
      Downloading https://files.pythonhosted.org/packages/07/a7/0b19c8f9476a4762d296c6c5fa860f2fe580a4f579fa53aaa8515f4ca217/scs-2.1.0.tar.gz (154kB)
        100% |################################| 163kB 11.1MB/s 
    Collecting multiprocess (from cvxpy[glpk])
      Downloading https://files.pythonhosted.org/packages/31/60/6d74caa02b54ca43092e745640c7d98f367f07160441682a01602ce00bc5/multiprocess-0.70.7.tar.gz (1.4MB)
        100% |################################| 1.4MB 6.4MB/s 
    Collecting fastcache (from cvxpy[glpk])
      Downloading https://files.pythonhosted.org/packages/fb/98/93f2d36738868e8dd5a8dbfc918169b24658f63e5fa041fe000c22ae4f8b/fastcache-1.0.2.tar.gz
    Collecting six (from cvxpy[glpk])
      Using cached https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
    Collecting numpy>=1.15 (from cvxpy[glpk])
      Using cached https://files.pythonhosted.org/packages/45/04/7a738e489a25a9638520a43a0cbfcc4be3ed056266e3110a330a905b36b5/numpy-1.16.2-cp35-cp35m-manylinux1_i686.whl
    Collecting scipy>=1.1.0 (from cvxpy[glpk])
      Downloading https://files.pythonhosted.org/packages/19/7b/fdd034bbd1c266b05bc5c38bc91e6733c0e19bc9d3630fd32d869998b6e3/scipy-1.2.1-cp35-cp35m-manylinux1_i686.whl (21.3MB)
        100% |################################| 21.3MB 374kB/s 
    Collecting cvxopt>=1.2.0 (from cvxpy[glpk])
      Downloading https://files.pythonhosted.org/packages/aa/a7/fe5b9b83caac402ecf58fe4420a94b16e8e530c05138343fc1977a5c1c58/cvxopt-1.2.3-cp35-cp35m-manylinux1_i686.whl (8.0MB)
        100% |################################| 8.0MB 2.0MB/s 
    Collecting future (from osqp>=0.4.1->cvxpy[glpk])
    Collecting dill>=0.2.9 (from multiprocess->cvxpy[glpk])
      Downloading https://files.pythonhosted.org/packages/fe/42/bfe2e0857bc284cbe6a011d93f2a9ad58a22cb894461b199ae72cfef0f29/dill-0.2.9.tar.gz (150kB)
        100% |################################| 153kB 3.1MB/s 
    Building wheels for collected packages: cvxpy, scs, multiprocess, fastcache, dill
      Building wheel for cvxpy (setup.py) ... done
      Stored in directory: /tmp/pip-ephem-wheel-cache-10tza7d7/wheels/0e/7c/42/bc3294fba335fafe64e2ae05be0ce1b671bbe20244056cecae
      Building wheel for scs (setup.py) ... done
      Stored in directory: /home/phd/.cache/pip/wheels/94/e2/a6/64db723051c54017c248ea5a26e7f1459c0242d735a496dd55
      Building wheel for multiprocess (setup.py) ... done
      Stored in directory: /home/phd/.cache/pip/wheels/3a/ed/51/77c833462c3e757ce50c4b2b68bdf53f5d1745542fe567d740
      Building wheel for fastcache (setup.py) ... done
      Stored in directory: /home/phd/.cache/pip/wheels/b7/90/c0/da92ac52d188d9ebca577044e89a14d0e6ff333c1bcd1ebc14
      Building wheel for dill (setup.py) ... done
      Stored in directory: /home/phd/.cache/pip/wheels/5b/d7/0f/e58eae695403de585269f4e4a94e0cd6ca60ec0c202936fa4a
    Successfully built cvxpy scs multiprocess fastcache dill
    Installing collected packages: future, numpy, scipy, osqp, ecos, scs, dill, multiprocess, fastcache, six, cvxopt, cvxpy
    Successfully installed cvxopt-1.2.3 cvxpy-1.0.21 dill-0.2.9 ecos-2.0.7.post1 fastcache-1.0.2 future-0.17.1 multiprocess-0.70.7 numpy-1.16.2 osqp-0.5.0 scipy-1.2.1 scs-2.1.0 six-1.12.0
    

    【讨论】:

    • 不幸的是,这不起作用。同样的错误:cvxpy 1.0.21 does not provide the extra 'glpk'
    • 为我工作。查看更新。您是否使用了该命令:pip install 'git+https://github.com/cvxgrp/cvxpy.git#egg=cvxpy[glpk]'
    • 它适用于我的 linux 机器,但不适用于我的 Windows 机器。但无论如何,我的 linux 机器上已经有了 GLPK。什么会导致它在 Windows 上的行为有所不同?
    • 不知道。我在Debian上试过。而且我没有安装 GLPK。
    • 您是否需要为cmd 使用不同风格的引号? pip install "git+https://github.com/cvxgrp/cvxpy.git#egg=cvxpy[glpk]"
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-12-06
    • 2020-02-16
    • 2020-01-27
    • 2016-05-03
    • 2020-12-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多