快速运行时和 .p 文件

Quickly runtime and .p files

我正在尝试在 python 中快速构建一个应用程序,大多数情况下一切正常,但是当我尝试 运行 一个读取 .p(pickle)文件的函数时,我得到一个 I/O错误。奇怪的是,当我 运行 在 shell 中运行相同的 python 程序时,它工作正常。

 adam@adam-System-Product-Name:~/reskin/reskin$ quickly run    
      2, No such file or directory,  newSnapShots.p 
    Traceback (most recent call last):
      File "bin/reskin", line 36, in <module> 
        reskin.main()
      File "/home/adam/reskin/reskin/__init__.py", line 31, in main
        window = ReskinWindow.ReskinWindow()
      File "/home/adam/reskin/reskin_lib/Window.py", line 37, in __new__
        new_object.finish_initializing(builder)
      File "/home/adam/reskin/reskin/ReskinWindow.py", line 36, in finish_initializing
        self.set_app_data(builder) 
      File "/home/adam/reskin/reskin/ReskinWindow.py", line 43, in set_app_data
        viewControler.app_by_name("firstVar")
      File "/home/adam/reskin/reskin/back/viewControler.py", line 29, in app_by_name
        app = applicationGetter.get_app_by_name(name)
      File "/home/adam/reskin/reskin/back/applicationGetter.py", line 8, in get_app_by_name
        for snap in savedSnaps:
    TypeError: 'bool' object is not iterable

打印错误的函数:

def get_saved_snaps():
try:
    with open('data/newSnapShots.p','rb') as snapFile:
        savedSnaps = pickle.load(snapFile)

except IOError as e:
    print "{0}, {1},  newSnapShots.p ".format(e.errno, e.strerror)
    return False

return savedSnaps

文件树和 .p 位置

.
├── applicationGetter.py
├── applicationGetter.pyc
├── data
│   └── newSnapShots.p    < file here
├── firstTimeSnapList.py
├── __init__.py
├── __init__.pyc
├── prosessCheckerv3.py
├── prosessScript.sh
├── viewControler.py
└── viewControler.pyc

快速使用 Cpickle 是否存在一些问题,我应该改用其他东西吗? 先感谢您。

稍作研究后发现,动态或相对文件路径在快速执行时难以执行。所以通过切换

  def get_saved_snaps():
try:
    with open('data/newSnapShots.p','rb') as snapFile:

对于

def get_saved_snaps():
try:
    with open('/absolute_path/quickly_project/data/newSnapShots.p','rb') as snapFile:

问题已解决。我不知道为什么相对路径会这样。