Gurobi mixed integer linear programming backend for SageMath. Source repository for https://pypi.org/project/sage-numerical-backends-gurobi/, can be installed on top of distributions providing SageMath. See also https://github.com/sagemath/sage-numerical-backends-cplex and https://github.com/sagemath/sage-numerical-backends-coin
GNU General Public License v2.0
7
stars
6
forks
source link
Error compiling gurobi backend (undeclared name not building: str_to_bytes) #4
I get a compilation error when I try to install the gurobi backend by running the command "sage -python -m pip install sage-numerical-backends-gurobi". I have gurobi 9.03 and sage 8.1 installed in Ubuntu 18.04.5 LTS.
$ sage -python -m pip install sage-numerical-backends-gurobi
Collecting sage-numerical-backends-gurobi
Using cached https://files.pythonhosted.org/packages/27/be/2a9b8999c2e79c9af2432155af6abc6a8a5cb4fc558d2178dbb2e888293d/sage_numerical_backends_gurobi-9.0.0.tar.gz
Complete output from command python setup.py egg_info:
Using gurobi_include_directories=['/opt/gurobi903/linux64/include'], libraries=['gurobi90'], library_dirs=['/opt/gurobi903/linux64/lib']
Checking whether HAVE_SAGE_CPYTHON_STRING...
Checking whether HAVE_ADD_COL_UNTYPED_ARGS...
Error compiling Cython file:
------------------------------------------------------------
...
from sage.numerical.backends.generic_backend cimport GenericBackend
cdef class TestBackend(GenericBackend):
cpdef add_col(self, indices, coeffs):
^
------------------------------------------------------------
check_add_col_untyped_args.pyx:4:10: Signature not compatible with previous declaration
Error compiling Cython file:
------------------------------------------------------------
...
cpdef set_verbosity(self, int level)
cpdef add_linear_constraint(self, coefficients, lower_bound, upper_bound, name=*)
cpdef add_linear_constraint_vector(self, degree, coefficients, lower_bound, upper_bound, name=*)
cpdef remove_constraint(self, int)
cpdef remove_constraints(self, constraints)
cpdef add_col(self, list indices, list coeffs)
^
------------------------------------------------------------
/usr/lib/python2.7/dist-packages/sage/numerical/backends/generic_backend.pxd:25:18: Previous declaration is here
Using compile_time_env: {'HAVE_ADD_COL_UNTYPED_ARGS': False, 'HAVE_SAGE_CPYTHON_STRING': False}
warning: sage_numerical_backends_gurobi/gurobi_backend.pyx:104:10: Compatible but non-identical C method 'add_variable' not redeclared in definition part of extension type 'GurobiBackend'. This may cause incorrect vtables to be generated.
warning: /usr/lib/python2.7/dist-packages/sage/numerical/backends/generic_backend.pxd:13:26: Previous declaration is here
Error compiling Cython file:
------------------------------------------------------------
...
cdef char * c_name = ""
if name is None:
name = b"x_" + bytes(self.ncols())
else:
name = str_to_bytes(name)
^
------------------------------------------------------------
sage_numerical_backends_gurobi/gurobi_backend.pyx:178:31: undeclared name not builtin: str_to_bytes
Error compiling Cython file:
------------------------------------------------------------
...
else:
check(self.env,GRBgetstrattr(self.model, "ModelName", <char **> pp_name))
if pp_name[0] == NULL:
value = ""
else:
value = char_to_str(pp_name[0])
^
------------------------------------------------------------
sage_numerical_backends_gurobi/gurobi_backend.pyx:442:39: undeclared name not builtin: char_to_str
Compiling sage_numerical_backends_gurobi/gurobi_backend.pyx because it changed.
[1/1] Cythonizing sage_numerical_backends_gurobi/gurobi_backend.pyx
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-tz2iGm/sage-numerical-backends-gurobi/setup.py", line 165, in <module>
compile_time_env=compile_time_env),
File "/usr/lib/python2.7/dist-packages/Cython/Build/Dependencies.py", line 1027, in cythonize
cythonize_one(*args)
File "/usr/lib/python2.7/dist-packages/Cython/Build/Dependencies.py", line 1149, in cythonize_one
raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: sage_numerical_backends_gurobi/gurobi_backend.pyx
----------------------------------------
I have noticed that the version of sage in the official Ubuntu 10.04 packages is too old. I have downloaded and installed the latest version binaries (version 9.1) and the problem has been fixed.
I get a compilation error when I try to install the gurobi backend by running the command "sage -python -m pip install sage-numerical-backends-gurobi". I have gurobi 9.03 and sage 8.1 installed in Ubuntu 18.04.5 LTS.