如何修复ManPy中的“导入错误:无法导入名称机器”错误

时间:2019-03-28 02:25:52

标签: python simpy

from dream.simulation.imports import Source, Queue, Machine, Exit
from dream.simulation.Globals import runSimulation

# define the objects of the model
S = Source('S1', 'Source', interArrivalTime={'Fixed': {'mean': 0.5}},
              entity='Dream.Part')
Q = Queue('Q1', 'Queue', capacity=1)
M = Machine('M1', 'Machine', processingTime={'Fixed': {'mean': 0.25}})
E = Exit('E1', 'Exit')
# define predecessors and successors for the objects
S.defineRouting(successorList=[Q])
Q.defineRouting(predecessorList=[S], successorList=[M])
M.defineRouting(predecessorList=[Q], successorList=[E])
E.defineRouting(predecessorList=[M])


def main(test=0):
     # add all the objects in a list
     objectList = [S, Q, M, E]
     # set the length of the experiment
     maxSimTime = 1440.0
     # call the runSimulation giving the objects and the length of the experiment
     runSimulation(objectList, maxSimTime)
     # calculate metrics
     working_ratio = (M.totalWorkingTime / maxSimTime) * 100
     # return results for the test
     if test:
          return {"parts": E.numOfExits, "working_ratio": working_ratio}

     # print the results
     print "the system produced", E.numOfExits, "parts"
     print "the total working ratio of the Machine is", working_ratio, "%"


if __name__ == '__main__':
     main()

然后我收到以下消息:

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

文件“您的目录/dream3/dream/stone/test1.py”的第6行     从dream.simulation.imports导入源,队列,计算机,退出

文件“您的目录\ dream3 \ dream \ simulation \ imports.py”,第38行,在     从dream.simulation.Machine导入机

文件“您的目录\ dream3 \ dream \ simulation \ Machine.py”,第36行,在     从SkilledOperatorRouter导入SkilledRouter

文件“您的目录\ dream3 \ dream \ simulation \ SkilledOperatorRouter.py”,第32行,在     导入Globals

文件“您的目录\ dream3 \ dream \ simulation \ Globals.py”,第29行,在     从机器导入机器

ImportError:无法导入名称计算机

1 个答案:

答案 0 :(得分:1)

早上好,先生! 为了它的价值,有人将该库移植到了Python 3 https://github.com/datarevenue-berlin/manpy 我安装了此仓库,示例正在运行!