Install Pyomo on Windows with Anaconda (Python)

I would like to solve LP and ILP with Pyomo (Coopr) , but unfortunately I am so new and I can not start it properly.

I already installed Pyomo (Coopr) by following its instructions

pip install Coopr 

I can import the module without problems:

 $ python Python 2.7.5 |Anaconda 1.8.0 (64-bit)| ... Type "help", "copyright", "credits" or "license" for more information. >>> import coopr.pyomo >>> 

At this point, I get lost, because I can not find the path in which I theoretically installed the package (/coopr.pyomo/examples/pyomo/diet).

I think I need to create an environment , but I recently read that it is now better to integrate with conda v. 2.1 (link)

There is a conda branch (new-pypi-install) which adds better integration with pip and PyPI. In particular, the conda list will also show that the packages installed for the package and conda install will first try to find the conda package and cannot use the package to install the package.

My ultimate goal is to implement this on an IPython laptop and get the results as output.

Note. I am trying to run a demo file

 pyomo diet1.py diet.dat 
+6
source share
1 answer

This is 2017, and pyomo can be easily installed via conda

 conda install -c conda-forge pyomo pyomo.extras 

Conda can also be used to install LP and NLP solvers.

 conda install -c cachemeorg glpk ipopt_bin 

If you are on a Mac or Linux, you can install updated versions using conda-forge.

 conda install -c conda-forge glpk ipopt 

If you prefer to install pyomo or solvers via pip:

Make sure that the PATH in the windows where pyomo.exe is located is really C: \ Anaconda \ Scripts

Also, PATH was set correctly since cmd recognized the pyomo command at the beginning

WITH

 echo %path% 

on cmd you can get a list of all the paths (where C: \ Anaconda \ Scripts \ "is included

So, with Anaconda, you had to set the path where glpsol.exe is located in order to do this from cmd.exe and considering that you unpacked your winglpk to "C: \ glpk \ w64":

 setx path "%path%;c:\glpk\w64" 

After that, restart cmd and go with the "cd" command, where you have data.py and data.dat

Finally it works! Thanks to the pyomo project mailing list for testimonials

For more information, I recommend reading the following links:

wingplk: http://en.wikibooks.org/wiki/GLPK/Windows_executables

setting the path in windows 7: http://www.voidspace.org.uk/python/articles/command_line.shtml https://superuser.com/questions/284342/what-are-path-and-other-environment-variables -and-how-can-i-set-or-use-them

+7
source

Source: https://habr.com/ru/post/957912/


All Articles