我该如何解决 "com.fasterxml.jackson.core.JsonParseException" 问题?

how can i resolve "com.fasterxml.jackson.core.JsonParseException" problem?

我在使用 Notebook 运行 Azure Synapse Analytics 上的代码时遇到了这个问题。

我运行这个代码

# Instantiate our problem class
model = pulp.LpProblem("Profit_maximising_problem", LpMaximize)

A = pulp.LpVariable('A', lowBound=0, cat='Integer')
B = pulp.LpVariable('B', lowBound=0, cat='Integer')

# Objective function
model += 30000 * A + 45000 * B, "Profit"

# Constraints
model += 3 * A + 4 * B <= 30
model += 5 * A + 6 * B <= 60
model += 1.5 * A + 3 * B <= 21

# Solve our problem
model.solve()
pulp.LpStatus[model.status]

# Print our decision variable values
print "Production of Car A = {}".format(A.varValue)
print "Production of Car B = {}".format(B.varValue)

# Print our objective function value
print pulp.value(model.objective)

我从这个 link http://benalexkeen.com/linear-programming-with-python-and-pulp-part-3/.

得到了这段代码

所以,我一步一步来,但是当我 运行 model.solve() 我会得到这样的错误。

1. com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'Welcome': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
 at [Source: (String)"Welcome to the CBC MILP Solver "; line: 1, column: 8]

2. com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'command': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
 at [Source: (String)"command line - /home/trusted-service-user/cluster-env/env/lib/python3.8/site-packages/pulp/apis/../solverdir/cbc/linux/64/cbc /tmp/29f229eb8406409583a8333341306957-pulp.mps max timeMode elapsed branch printingOptions all solution /tmp/29f229eb8406409583a8333341306957-pulp.sol (default strategy 1)"; line: 1, column: 8]

3. com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'At': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
 at [Source: (String)"At line 3 ROWS"; line: 1, column: 3]

4. com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'At': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
 at [Source: (String)"At line 80 ENDATA"; line: 1, column: 3]

每次我重新运行代码时,我都会收到另一个错误...如您所见,共有 4 种类型。

我的条件是我需要 运行 使用 azure notebook 在 azure 突触分析上进行它。

如果您有任何建议或意见请告诉我。

非常感谢!

要解决此 com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'Welcome': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false') 错误,请尝试以下任一方法:

根据的建议:

  • 似乎 Jackson 包正在尝试转换日志并抛出 JsonParseException,通过 msg=False

    model.solve(PULP_CBC_CMD(msg=False))

根据Imolkova的建议: