fateme krm
fateme krm

Reputation: 3

install glpk error while Building a wheel for glpk (PEP 517) ... none of ways worked

im going to solve Linear Programming Problem and so i need "pulp" library, but while executing a simple code;

# solve the problem
status = myLpProblem.solve(GLPK(msg=1))

THIS ERROR HAPPENS: PuLP: cannot execute glpsol.exe

so i try to install "glpk" but i faced with this error:

 Building wheel for glpk (PEP 517) ... error   ERROR: Command errored out with exit status 1:    command: 'c:\users\karmian\venv\scripts\python.exe' 'c:\users\karmian\venv\lib\site-packages\pip\_vendor\pep517\_in_process.py' build_wheel 'C:\Users\Karmian\AppData\Local\Temp\tmp994fjkt2'
       cwd: C:\Users\Karmian\AppData\Local\Temp\pip-install-q1cmpyrg\glpk   Complete output (5 lines):   running bdist_wheel   running build   running build_ext   building 'glpk' extension   error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/  
----------------------------------------   ERROR: Failed building wheel for glpk Failed to build glpk ERROR: Could not build wheels for glpk which use PEP 517 and cannot be installed directly

I try different way people suggest, like

-upgrade,downgrade pip,wheel ,python

and none of them worked! of course i doubted about whether i installed Microsoft Visual C++ 14.0 truely or not, cause after download installer, i didn't change default setting(i dont know what i should change)and directly press install ,(settings on workload tab,installation locations and..) i had also some constraints .( for example if i choose "C++ build tools" in first tab it needs 6 gig capacity to install,which i had not. picture of installer setting is available here should i change setting?

please help me to find a solution or better "optimization library" instead of "pulp"

im using :

  1. virtual env python environment
  2. visual studio as my editor of python
  3. last version of python:3.8.1(i try some older versions too)
  4. pip version 20.2.3

Upvotes: 0

Views: 5071

Answers (1)

thetroubledbear
thetroubledbear

Reputation: 31

after many days of troubleshooting I found a way that may work for you too. I know that you're on windows, if you adjust it on your os this might help

This worked on mint and on my Mac.

Firstly you have to download the latest version of glpk from their website, http://ftp.gnu.org/gnu/glpk/

After downloading put it in a folder(do not uncompress it yet) cd into that folder and run this command $ tar -xzf glpk5.0.tar.gz

Then you have to configure it, as of my knowledge the problem on Mac was an issue of permissions. $ ./configure --prefix=/usr/local

Now you have to compile it by running make

Lastly $ sudo make install

It should take some time in the last 2 steps.

If everything went fine you can check with these two commands

$ which glpsol

$ glpsol --help

Last but not least you run $ pip3 install glpk

This is the way that worked for me, I hope it will help someone else too. :)

Upvotes: 3

Related Questions