or-fusion / pyomo_simplemodel

An extension of Pyomo that defines a simple modeling class that is similar to PuLP
Other
6 stars 6 forks source link

Fails on "from pyomo.contrib.simplemodel import *" #5

Closed amarvin closed 5 years ago

amarvin commented 5 years ago

I used pip to install pyomo and pyomocontrib_simplemodel into a Docker container, but then import statement

from pyomo.contrib.simplemodel import *

fails with this partial trace:

Installing collected packages: pyparsing, pulp, appdirs, nose, PyUtilib, ply, pyomo, pyomocontrib-simplemodel
Successfully installed PyUtilib-5.6.5 appdirs-1.4.3 nose-1.3.7 ply-3.11 pulp-1.6.9 pyomo-5.6.1 pyomocontrib-simplemodel-1.0.1 pyparsing-2.3.1

ImportError: Failed to import test module: sudoku
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/pyomo/contrib/simplemodel/__init__.py", line 2, in <module>
    from pyomocontrib_simplemodel import *
  File "/usr/local/lib/python3.6/dist-packages/pyomocontrib_simplemodel/__init__.py", line 1, in <module>
    from pyomo.util.plugin import PluginGlobals
ModuleNotFoundError: No module named 'pyomo.util.plugin'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/unittest/loader.py", line 462, in _find_test_path
    package = self._get_module_from_name(name)
  File "/usr/lib/python3.6/unittest/loader.py", line 369, in _get_module_from_name
    __import__(name)
  File "/builds/SudermN/SudokuTeaching/sudoku/__init__.py", line 1, in <module>
    from sudoku.sudoku import *
  File "/builds/SudermN/SudokuTeaching/sudoku/sudoku.py", line 2, in <module>
    from pyomo.contrib.simplemodel import Binary, SimpleModel, value
  File "/usr/local/lib/python3.6/dist-packages/pyomo/contrib/simplemodel/__init__.py", line 8, in <module>
    "The pyomocontrib_simplemodel package is not installed.")
RuntimeError: The pyomocontrib_simplemodel package is not installed.

Am I missing a dependency or using the wrong versions?

amarvin commented 5 years ago

Looks like the TravisCI build includes miniconda in the Docker image. Maybe something from there should be added as a requirement in setup.py.

amarvin commented 5 years ago

Might also be something from pyomo.extras (which doesn't seem to be available with pip, but is available with conda https://anaconda.org/conda-forge/pyomo.extras)

whart222 commented 5 years ago

Dang. I think I need to cut a new release of simplemodel. We just cut a new release of pyomo, and I forgot to check. I'll do this later tonight.

whart222 commented 5 years ago

FYI, the master branch works. I'm trying to resolve a testing issue before cutting the release.

amarvin commented 5 years ago

Thanks for the fast response, William! I'll try the master branch.

amarvin commented 5 years ago

Looks like this won't solve my issue, as installing pyomo with pip doesn't install extras, which seem to be required by Pyomo SimpleModel.

amarvin commented 5 years ago

I added pyomo install-extras to install pyomo.extras, but still get the same error when trying to import simplemodel. Looking at Pyomo, I don't see a module pyomo.util.plugin

amarvin commented 5 years ago

I'm using Python 3.6.7, btw.

whart222 commented 5 years ago

I don't see the dependency on extras. Can you send me an error message related to that? The Pyomo 5.6 release removed the pyomo.util.plugin module, which is the source of this error. We definitely need a new release of simple model. Working on that now.

whart222 commented 5 years ago

I just tagged SimpleModel 1.0.2, which should resolve this issue. I'm updating PyPI and Conda packages now.

whart222 commented 5 years ago

I guess I never created a conda-forge package. That's a longer lead-time. But I uploaded the release to PyPI.

amarvin commented 5 years ago

Oh, I see. Just tried v1.0.2 from PyPI, and it worked! Nice work!

You're right that there's no dependency on pyomo.extras, but I saw you included it in the Travis-CI build, so I tried that in troubleshooting.