-1

我只是从https://pypi.python.org/pypi/ortools安装 ortools 6.5.4527

使用 exe 安装程序

ortools-6.5.4527.win-amd64-py3.6.exe (md5)

测试.py

    from __future__ import print_function
    from ortools.linear_solver import pywraplp

    def main():
        solver = pywraplp.Solver('SolveSimpleSystem',
        pywraplp.Solver.GLOP_LINEAR_PROGRAMMING)
        x = solver.NumVar(0, 1, 'x')
        y = solver.NumVar(0, 2, 'y')
        objective = solver.Objective()
        objective.SetCoefficient(x, 1)
        objective.SetCoefficient(y, 1)
        objective.SetMaximization()
        solver.Solve()
        print('Solution:')
        print('x = ', x.solution_value())
        print('y = ', y.solution_value())

    if __name__ == '__main__':
        main()

我得到这个错误

    PS C:\Users\George\Documents\GitHub\GEORGE\products-offers-combinations> python or_tools.py
    Traceback (most recent call last):
      File "C:\Users\George\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ortools\linear_solver\pywraplp.py", line 14, in swig_import_helper
        return importlib.import_module(mname)
      File "C:\Users\George\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 978, in _gcd_import
      File "<frozen importlib._bootstrap>", line 961, in _find_and_load
      File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 648, in _load_unlocked
      File "<frozen importlib._bootstrap>", line 560, in module_from_spec
      File "<frozen importlib._bootstrap_external>", line 922, in create_module
      File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
    ImportError: DLL load failed: Το %1 δεν είναι έγκυρη εφαρμογή Win32.

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "or_tools.py", line 16, in <module>
        from ortools.linear_solver import pywraplp
      File "C:\Users\George\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ortools\linear_solver\pywraplp.py", line 17, in <module>
        _pywraplp = swig_import_helper()
      File "C:\Users\George\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ortools\linear_solver\pywraplp.py", line 16, in swig_import_helper
        return importlib.import_module('_pywraplp')
      File "C:\Users\George\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
    ModuleNotFoundError: No module named '_pywraplp'
    PS C:\Users\George\Documents\GitHub\GEORGE35\products-offers-combinations>
4

1 回答 1

0

pip3.6 安装 ortools <==== WORKS

于 2017-10-25T14:48:46.643 回答