Python pickling after changing a module's directory

前端 未结 5 1812
生来不讨喜
生来不讨喜 2020-11-30 00:22

I\'ve recently changed my program\'s directory layout: before, I had all my modules inside the \"main\" folder. Now, I\'ve moved them into a directory named after the progra

5条回答
  •  日久生厌
    2020-11-30 00:57

    Happened to me, solved it by adding the new location of the module to sys.path before loading pickle:

    import sys
    sys.path.append('path/to/whiteboard')
    f = open("pickled_file", "rb")
    pickle.load(f)
    

提交回复
热议问题