python - ImportError on pickle.load for object -
when trying load file pickle getting importerror: no module named application_mgmt.
strangely same file can loaded no problem form different function both use same get_file method , all. strangely can load of other files function.
i have tried moving functions different class/file. clearing , re-populating saved file nothing seems work.
the object in saved file:
class application(): def __init__(self,name,focus=false): self.name = name self.focus = focus self.prod_score = 5 self.display_name = name self.color = "none" function causes error:
def check_meta_info(self, app_name): self.get_file("saved_meta_data") file handling function:
def get_file(self, file_name): path = "back/saved_data/%s" % (file_name) try: open(path,'rb') saved_file: saved_list = pickle.load(saved_file) saved_file.close() return saved_list except ioerror: #stuff log:
traceback (most recent call last): file "<stdin>", line 400, in <module> file "<stdin>", line 221, in app_meta_info file "<stdin>", line 313, in check_meta_info file "<stdin>", line 358, in get_file importerror: no module named application_mgmt shell returned 1 the function works calls same file class:
def add_meta_info(self, new_application): new_meta = application(new_application) # creates obj saved_meta_info = self.get_file("saved_meta_data") metas in saved_meta_info: if new_meta.name == metas.name: return false saved_meta_info.append(new_meta) self.save_file(saved_meta_info,"saved_meta_data") del new_meta file structure:
. ├── active_screen.glade ├── active_screen.py ├── │ ├── application_mgmt.py │ ├── application_mgmt.pyc │ ├── bash │ │ ├── get_active_window.sh │ │ ├── prosessscript.sh │ │ └── test_lock.sh │ ├── bash_schedular.py │ ├── __init__.py │ ├── __init__.pyc │ ├── saved_data │ │ ├── first_time_builder.py │ │ ├── saved_active_data │ │ ├── saved_background_data │ │ ├── saved_ignore_data │ │ └── saved_meta_data < him
looking @ error log, don't think problem has pickle loading. don't know why he's trying import application_mgmt - line of get_file 358th ? - importerror caused :
forgetting __init__file in back folder. folder not importable without it. create empty 1 if it's missing.
python path problem : check if that's problem, try adding @ beginning of get_file method.
import sys sys.path.append('/path/to/the/back/module/')circular imports : if find - between application_mgmt.py , file -, try refactoring code avoid them.
hope helps.
Comments
Post a Comment