I installed the pyomo and the glpk package and implemented a model with a data file. I want to use the pyomo command line to run it on Windows 10 using the following command on the command line:
pyomo solve --solver=glpk wl_abstract.py wl_data.dat
However the pyomo is not an executable! How do I proceed? Where can I find the pyomo executable?
Thank for help
Related
I am new to Pyomo and would love to use it and call GLPK or CBC. However, I am struggling to get any of them working, perhaps I am not able to install and call them correctly. I am using windows and would appreciate any input.
Here is an error message I am receiving:
"Could not locate the 'glpsol' executable, which is required for solver 'glpk'"
I am using python 3.6.
UPDATE june 18:
I would like compiling my python code for windows.
I use to work with pyinstaller, python 3.5+, windows 7 and anaconda to control modules pandas, pyqt (v5) and pyqtgraph, but it seems something is not compatible. I would not be surprised if you tell me to change a version.
In previous versions, it worked with python 3.5, windows 7 and Pyinstaller 3.3.1- without pandas; the new version imports pandas and then this doesn’t work anymore:
with the usual config pyinstaller gives a message saying the C libraries are not built. Following the instructions, I should run python setup.py build_ext --inplace --force, except I don’t see the setup.py file, so I don’t know what to do. Forums tell me it should be a problem with pip but not with conda… but I use conda…
with python 3.6, I got an error message ‘RecursionError: maximum recursion depth exceeded’ (https://github.com/steph2016/profiles/blob/master/errorMessage). This problem seems known and solutions I found on forums is either to downgrade python or to replace my PyInstaller-3.3.1 by PyInstaller-3.4.dev0+7b3143612. But with PyInstaller-3.4.dev0+7b3143612 I get a ’’str’ object has no attribute ‘items’’ error (https://github.com/steph2016/profiles/blob/master/ErrorMessage2). I’m not sure pyinstaller is compatible with python 3.6…
with python 3.4, I got an error similar to the ‘str object’ one above. I’m not sure python3.4 is compatible with qt5…
I would be pleased by any solution with any version of whatever to windows-compile my code
I don't know if it is the issue but I didn't find PyQtGraph in Supported-Packages
I eventually applied the first solution proposed in No module named 'pandas._libs.tslibs.timedeltas' in PyInstaller in the original config (python 3.5, PyInstaller 3.3.1, pyqtgraph, pandas, windows 7,...) and it worked.
I don't know why adding def get_pandas_path ..... a.binaries) helps, so I can't justify. But just to be explicit even if it seems obvious: pyinstaller must be run on the spec file, not on the py one (for instance > pyinstaller toto.spec)
So I've installed scons via Anaconda's conda install scons under Windows 10 (Python 3.6) and could not execute it via the command line so I've added C:\Users\D\Anaconda3\envs\py36\Scripts\ to my Path (even tough C:\Users\Dominik\Anaconda3 was already in there).
Now I can execute it in the Powershell, but I get an error, because it is unable find engine files:
scons
SCons import failed. Unable to find engine files in:
C:\Users\D\Anaconda3\envs\py36\Scripts\..\engine
C:\Users\D\Anaconda3\envs\py36\Scripts\scons-local-3.0.1
C:\Users\D\Anaconda3\envs\py36\Scripts\scons-local
C:\Users\D\Anaconda3\scons-3.0.1
C:\Users\D\Anaconda3\Lib\site-packages\scons-3.0.1
C:\Users\D\Anaconda3\scons
C:\Users\D\Anaconda3\Lib\site-packages\scons
Traceback (most recent call last):
File "C:\Users\D\Anaconda3\envs\py36\Scripts\scons.py", line 192, in <module>
import SCons.Script
ImportError: No module named 'SCons'
Does someone know how to further investigate/fix this problem?
I found it thanks to nekomatic.
If you use the anaconda prompt (with the correct environment activated or in my case the correct shortcut leading to anaconda prompt in that environment), scons runs just fine.
See this link explaining how anaconda uses the path on windows and whats the advantage of using the anaconda prompt (mainly it dynamically manages PATH correctly for that session only with full knowledge of conda environments).
I am trying to solve a MILP problem set up in PYOMO whith SCIP as solver.
I run the problem from within PyDev using the python ANACONDA interpreter.
I can run and solve the problem with other solvers, namely CBC, GLPK, and IPOPT.
However, it does not work when using SCIP as solver. It seems like there is something wrong with the SCIP/AMPL interface... Anybody can help out?
Below are some details on the error prompt and system configuration.
I tried with 'scip' and 'scipampl'.
With 'scip'
opt = SolverFactory('scip')
instance = model.create_instance("test1.dat")
results = opt.solve(instance)
instance.display()
WARNING: "[base]/site-packages/pyomo/solvers/plugins/solvers/SCIPAMPL.py", 68, _default_executable
Could not locate the 'scipampl' executable, which is required for solver scip
Traceback (most recent call last):
File "/home/alessandro/Documents/Eclipse workspace/test1/src/test1.py", line 48, in
results = opt.solve(instance) # solves and updates instance
File "/home/alessandro/anaconda3/lib/python3.6/site-packages/pyomo/opt/base/solvers.py", line 539, in solve
self.available(exception_flag=True)
File "/home/alessandro/anaconda3/lib/python3.6/site-packages/pyomo/opt/solver/shellcmd.py", line 122, in available
raise ApplicationError(msg % self.name)
pyutilib.common._exceptions.ApplicationError: No executable found for solver 'scip'
With 'scipampl'
opt = SolverFactory('scipampl')
instance = model.create_instance("test1.dat")
results = opt.solve(instance)
instance.display()
WARNING: "[base]/site-packages/pyomo/opt/base/solvers.py", 202, solver_call
Failed to create solver with name 'scipampl':
Failed to set executable for solver asl. File with name=scipampl either does not exist or it is not executable. To skip this validation, call set_executable with validate=False.
Traceback (most recent call last):
File "/home/alessandro/Documents/Eclipse workspace/test1/src/test1.py", line 48, in
results = opt.solve(instance)
File "/home/alessandro/anaconda3/lib/python3.6/site-packages/pyomo/opt/base/solvers.py", line 127, in solve
self._solver_error('solve')
File "/home/alessandro/anaconda3/lib/python3.6/site-packages/pyomo/opt/base/solvers.py", line 155, in _solver_error
+ "\n\toptions: %s" % ( self.options, ) )
RuntimeError: Attempting to use an unavailable solver.
The SolverFactory was unable to create the solver "scipampl"
and returned an UnknownSolver object. This error is raised at the point
where the UnknownSolver object was used as if it were valid (by calling
method "solve").
The original solver was created with the following parameters:
executable: scipampl
type: scipampl
_args: ()
options: {}
The Eclipse version is "Oxygen.1 (4.7.1)" and the PyDev version is "6.0.0".
The python, pyomo, and solvers versions are as follows:
~$ python
Python 3.6.2 |Anaconda custom (64-bit)| (default, Sep 30 2017, 18:42:57) [GCC 7.2.0] on linux
~$ pyomo --version
Pyomo 5.2 (CPython 3.6.2 on Linux 4.10.0-35-generic)
~$ cbc
Welcome to the CBC MILP Solver
Version: 2.9.9
Build Date: Jul 6 2017
~$ glpsol
GLPSOL: GLPK LP/MIP Solver, v4.63
~$ ipopt
No stub!
usage: ipopt [options] stub [-AMPL] [<assignment> ...]
~$ scip
SCIP version 4.0.1 [precision: 8 byte] [memory: block] [mode: optimized] [LP solver: SoPlex 3.0.1] [GitHash: 8a04b84]
Copyright (C) 2002-2017 Konrad-Zuse-Zentrum fuer Informationstechnik Berlin (ZIB)
External codes:
SoPlex 3.0.1 Linear Programming Solver developed at Zuse Institute Berlin (soplex.zib.de) [GitHash: 24cffa9]
CppAD 20160000.1 Algorithmic Differentiation of C++ algorithms developed by B. Bell (www.coin-or.org/CppAD)
ZLIB 1.2.8 General purpose compression library by J. Gailly and M. Adler (zlib.net)
GMP 6.1.0 GNU Multiple Precision Arithmetic Library developed by T. Granlund (gmplib.org)
ZIMPL 3.3.4 Zuse Institute Mathematical Programming Language developed by T. Koch (zimpl.zib.de)
Ipopt 3.12.8 Interior Point Optimizer developed by A. Waechter et.al. (www.coin-or.org/Ipopt)
user parameter file <scip.set> not found - using default parameters
SCIP> ^C
I installed the CBC, GLPK and IPOT packages as follows:
conda install -c conda-forge coincbc
conda install -c conda-forge glpk
conda install -c conda-forge ipopt
I installed the latest SCIPOPTSUITE version "4.0.1" with the Linux-Debian package "SCIPOptSuite-4.0.1-Linux.deb"
I also installed AMPL-MP SCIPOPTLIB and PYSCIPOPT as follows:
conda install -c conda-forge ampl-mp
conda install -c leethargo scipoptlib
conda install -c leethargo pyscipopt
EDIT:
follow these instructions: http://zverovich.net/2012/08/07/using-scip-with-ampl.html
Several things that might help:
the conda package at leethargo is not the official conda package (because there is none)
try installing and running PySCIPOpt via pip first
PySCIPOpt is not interfaced to PYOMO, so you most likely need to rely on AMPL for the SCIP support
does PYOMO even support SCIP? I couldn't figure that out from their documentation
Ah, look what I found after googling "pyomo scip":
https://groups.google.com/forum/#!topic/pyomo-forum/peBjIvkVwtQ
https://github.com/Pyomo/pyomo/issues/48
So, PYOMO only supports SCIP through the AMPL interface (ASL).
I followed the instructions in this link about Kivy installation "Using Homebrew with pip".
However, when I tried to run the code given below:
from kivy.app import App
from kivy.uix.button import Button
class TestApp(App):
def build(self):
return Button(text='Hello World')
TestApp().run()
It gave me an error:
bash: kivy: command not found
if you installed kivy with pip, you don't need a kivy command, you can use python directly.
python main.py
Because I created a virtual environment to isolate all the things that needs to be installed like kivy, and I installed cython and kivy first before the homebrew, it caused the problem. Even if I use:
python main.py
instead of
kivy main.py
What I did to solve it are the following:
1. Created a new virtual environment
2. Followed the instruction in kivy in right order: (1) homebrew, (2) Cython, then (3) Kivy.
3. Used "python" command instead of "kivy" command because I installed it using pip (refer to the commenr above). For example:
python name_of_your_file.py
Kivy documentation must be confusing that's why.