pysal / region

A library for Spatially-Explicit Regionalization
BSD 3-Clause "New" or "Revised" License
14 stars 16 forks source link

pulp currently does not support python 3.5+ #16

Closed jGaboardi closed 5 years ago

jGaboardi commented 5 years ago

pulp only supports python up to 3.4 and errors out when trying to import cplex due to no support . A direction to go may be dump pulp in favor of ortools for using Coin-or Branch Cut


Failure: Exception (CPLEX 12.8.0.0 is not compatible with this version of Python.) ... ERROR

======================================================================
ERROR: Failure: Exception (CPLEX 12.8.0.0 is not compatible with this version of Python.)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/cpu/miniconda3/envs/py3_spgh_dev/lib/python3.6/site-packages/nose/failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "/Users/cpu/miniconda3/envs/py3_spgh_dev/lib/python3.6/site-packages/nose/loader.py", line 417, in loadTestsFromName
    addr.filename, addr.module)
  File "/Users/cpu/miniconda3/envs/py3_spgh_dev/lib/python3.6/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/Users/cpu/miniconda3/envs/py3_spgh_dev/lib/python3.6/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/Users/cpu/miniconda3/envs/py3_spgh_dev/lib/python3.6/imp.py", line 245, in load_module
    return load_package(name, filename)
  File "/Users/cpu/miniconda3/envs/py3_spgh_dev/lib/python3.6/imp.py", line 217, in load_package
    return _load(spec)
  File "<frozen importlib._bootstrap>", line 684, in _load
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/cpu/region/region/__init__.py", line 2, in <module>
    from . import max_p_regions
  File "/Users/cpu/region/region/max_p_regions/__init__.py", line 1, in <module>
    from . import heuristics
  File "/Users/cpu/region/region/max_p_regions/heuristics.py", line 6, in <module>
    from region.objective_function import ObjectiveFunctionPairwise
  File "/Users/cpu/region/region/objective_function.py", line 6, in <module>
    from region.util import get_metric_function
  File "/Users/cpu/region/region/util.py", line 14, in <module>
    import pulp
  File "/Users/cpu/miniconda3/envs/py3_spgh_dev/lib/python3.6/site-packages/pulp/__init__.py", line 34, in <module>
    from .pulp import *
  File "/Users/cpu/miniconda3/envs/py3_spgh_dev/lib/python3.6/site-packages/pulp/pulp.py", line 102, in <module>
    from .solvers import *
  File "/Users/cpu/miniconda3/envs/py3_spgh_dev/lib/python3.6/site-packages/pulp/solvers.py", line 991, in <module>
    import cplex
  File "/Applications/CPLEX_Studio128/cplex/python/2.7/x86-64_osx/cplex/__init__.py", line 43, in <module>
    from .aborter import Aborter
  File "/Applications/CPLEX_Studio128/cplex/python/2.7/x86-64_osx/cplex/aborter.py", line 13, in <module>
    from ._internal import _procedural as _proc
  File "/Applications/CPLEX_Studio128/cplex/python/2.7/x86-64_osx/cplex/_internal/__init__.py", line 21, in <module>
    from . import _list_array_utils
  File "/Applications/CPLEX_Studio128/cplex/python/2.7/x86-64_osx/cplex/_internal/_list_array_utils.py", line 14, in <module>
    from . import _pycplex as CPX
  File "/Applications/CPLEX_Studio128/cplex/python/2.7/x86-64_osx/cplex/_internal/_pycplex.py", line 28, in <module>
    _pycplex_platform = swig_import_helper()
  File "/Applications/CPLEX_Studio128/cplex/python/2.7/x86-64_osx/cplex/_internal/_pycplex.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pycplex_platform', fp, pathname, description)
  File "/Users/cpu/miniconda3/envs/py3_spgh_dev/lib/python3.6/imp.py", line 235, in load_module
    return load_source(name, filename, file)
  File "/Users/cpu/miniconda3/envs/py3_spgh_dev/lib/python3.6/imp.py", line 172, in load_source
    module = _load(spec)
  File "/Applications/CPLEX_Studio128/cplex/python/2.7/x86-64_osx/cplex/_internal/_pycplex_platform.py", line 25, in <module>
    raise Exception(ERROR_STRING)
Exception: CPLEX 12.8.0.0 is not compatible with this version of Python.
ljwolf commented 5 years ago

Hmm....

I kind of feel that, at this point, the different submethods are so incompatible that it may make sense to use class-level dependencies for this module, if we decide to distribute it together as a module.

Otherwise, I think it make sense to restate this more generally for spatial optimization, merge in the LSCP/MCLP stuff here, and make this package a larger or-tools dependent module.

jGaboardi commented 5 years ago

interesting... a pysal/spopt module...

jGaboardi commented 5 years ago

@ljwolf I was wrong about pulp not supported in python 3. I was getting that error because I had a CPLEX_PATH environment variable set and pulp was attempting to import cplex internally. The problem there was with cplex, not pulp. I was able to run nosetests for region, and there are many failures, but at least now they can be run and we can stick with using pulp for this. Moreover, pulp now comes with a compiled Coin-or Branch Cut install (which I did not realize) and is available on conda-forge. I may be switching from ortools to pulp for that...

jGaboardi commented 5 years ago

resolved in #17