我编写了一个使用CVXPy库解决优化问题的简单代码。
from cvxpy import Variable, Minimize, Problem, abs
c = [20, 20, 50]
k = [-0.25, -0.15, -0.25, -0.35, -0.15, -0.25]
xbr_1, xbr_2 = Variable(1), Variable(1)
mra_1, mra_2 = Variable(1), Variable(1)
# Objective function
objective = Minimize(c[0] * abs(xbr_1) + c[1] * abs(xbr_2) +
c[2] * abs(mra_1) + c[2] * abs(mra_2))
# Right hand side of inequalities
rhs_1 = 1500
rhs_2 = 1400
lhs_1 = (k[0] * xbr_1 + k[1] * xbr_2 + k[2] * mra_1)
lhs_2 = (k[3] * xbr_1 + k[4] * xbr_2 + k[5] * mra_2)
# Problem constraints
constraints = [lhs_1 <= rhs_1,
lhs_2 <= rhs_2,
xbr_1 <= 1000,
xbr_2 <= 1000]
prob = Problem(objective, constraints)
# The optimal objective is returned by prob.solve().
result = prob.solve()
我想使用PyInstaller创建一个 exe 文件,我的版本是 3.1.1。附上编译过程的日志。编译过程成功完成。
当我尝试执行编译文件时,我收到以下错误消息:
C:\_Studna>brute_prog.exe
Traceback (most recent call last):
File "<string>", line 47, in <module>
File "C:\_Studna\Python\python-2.7.10.amd64\Lib\site-packages\PyInstaller-3.1.
1\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
exec(bytecode, module.__dict__)
File "C:\_Studna\Python\python-2.7.10.amd64\lib\win32com\__init__.py", line 5,
in <module>
import win32api, sys, os
File "C:\_Studna\Python\python-2.7.10.amd64\Lib\site-packages\PyInstaller-3.1.
1\PyInstaller\loader\pyimod03_importers.py", line 546, in load_module
module = imp.load_module(fullname, fp, filename, ext_tuple)
ImportError: DLL load failed: %1 not a valid Win32 application.
pyi_rth_win32comgenpy returned -1
任何人都可以提供一些建议吗?我发现这篇文章可能与该主题相关。