在虚拟环境中运行Pyomo时出错

时间:2019-07-05 05:50:50

标签: python pyomo virtual-environment

我想用pyomo在虚拟conda环境中解决优化问题。我用“ conda install-n envname packagename”安装了pyomo和glpk-Solver。当我测试求解器时,出现以下错误:

(venvconda) C:\Users\XXX\Synergy-Site>pyomo test-solvers glpk

回溯(最近通话最近一次):

File "C:\Users\XXX\AppData\Local\Continuum\anaconda3\envs\venvconda\Scripts\pyomo-script.py", line 10, in <module>
    sys.exit(main())
  File "\\xxxx\Anwendungsdaten\Python\Python37\site-packages\pyomo\scripting\pyomo_main.py", line 82, in main
    retval = _options.func(_options)
  File "\\xxxx\Anwendungsdaten\Python\Python37\site-packages\pyomo\opt\plugins\driver.py", line 31, in test_exec
    pyomo.solvers.tests.testcases.run_test_scenarios(options)
  File "\\xxxx\Anwendungsdaten\Python\Python37\site-packages\pyomo\solvers\tests\testcases.py", line 353, in run_test_scenarios
    rc = model_class.validate_current_solution(suffixes=model_class.test_suffixes)
  File "\\xxxx\Anwendungsdaten\Python\Python37\site-packages\pyomo\solvers\tests\models\base.py", line 205, in validate_current_solution
    with open(self.results_file,'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: '\\\\xxxx\\Anwendungsdaten\\Python\\Python37\\site-packages\\pyomo\\solvers\\tests\\models\\LP_block.json'

1 个答案:

答案 0 :(得分:0)

test-solvers脚本已经很老了,因此我建议尝试解决一个小型模型,以代替使用test-solvers脚本来测试安装。您可以通过在Anaconda提示符中运行命令glpsol来检查GLPK是否正确安装。您应该看到如下输出:

$ glpsol
GLPSOL: GLPK LP/MIP Solver, v4.62
No input problem file specified; try glpsol --help

可以找到{@ 3}}的小型Pyomo模型来测试您的安装