提问人:Arnoneel Sinha 提问时间:11/17/2023 更新时间:11/17/2023 访问量:14
在 Jupyter Notebook 中读取 .pkl 文件时出现 pyranges 的 ModuleError
ModuleError with pyranges when reading .pkl file in Jupyter Notebook
问:
我需要在 JupyterLab 中读取 .pkl 文件。我拥有的代码是:
import dill
# Loading scplus_obj
scplus_obj = dill.load(open('/path-to-my-file/scplus_obj.pkl', 'rb'))
错误 get 是:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[12], line 2
1 # Loading scplus_obj
----> 2 scplus_obj = dill.load(open('/path-to-my-file/scplus_obj.pkl', 'rb'))
File ~/.local/lib/python3.8/site-packages/dill/_dill.py:287, in load(file, ignore, **kwds)
281 def load(file, ignore=None, **kwds):
282 """
283 Unpickle an object from a file.
284
285 See :func:`loads` for keyword arguments.
286 """
--> 287 return Unpickler(file, ignore=ignore, **kwds).load()
File ~/.local/lib/python3.8/site-packages/dill/_dill.py:442, in Unpickler.load(self)
441 def load(self): #NOTE: if settings change, need to update attributes
--> 442 obj = StockUnpickler.load(self)
443 if type(obj).__module__ == getattr(_main_module, '__name__', '__main__'):
444 if not self._ignore:
445 # point obj class to main
File ~/.local/lib/python3.8/site-packages/dill/_dill.py:432, in Unpickler.find_class(self, module, name)
430 return type(None) #XXX: special case: NoneType missing
431 if module == 'dill.dill': module = 'dill._dill'
--> 432 return StockUnpickler.find_class(self, module, name)
ModuleNotFoundError: No module named 'pyranges.pyranges'
我尝试卸载然后安装 pyranges 模块。我已经在JupyterLab中安装了pyranges。
我已确保模块路径包含在系统路径中:
import pyranges
print(pyranges.__file__)
import sys
sys.path
/home/cbgm/.local/lib/python3.8/site-packages/pyranges/__init__.py
['/home/cbgm/.local/lib/python3.8/site-packages/ray/thirdparty_files',
'/home/cbgm',
'/usr/lib/python38.zip',
'/usr/lib/python3.8',
'/usr/lib/python3.8/lib-dynload',
'',
'/home/cbgm/.local/lib/python3.8/site-packages',
'/home/cbgm/scenicplus/src',
'/usr/local/lib/python3.8/dist-packages',
'/usr/lib/python3/dist-packages']
而不是,我也尝试过:dill
pickle
import pickle
with open('/path-to-my-file/scplus_obj.pkl', 'rb') as scplus_obj:
data = pickle.load(scplus_obj)
即便如此,我还是收到同样的错误:
/usr/lib/python3/dist-packages/paramiko/transport.py:219: CryptographyDeprecationWarning: Blowfish has been deprecated
"class": algorithms.Blowfish,
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[1], line 3
1 import pickle
2 with open('/media/cbgm/6e648ddc-311d-4572-ac67-f8a548f153d4/Neel/Shuchun Li/70_SCENICplus_outs/01_Data/scenicplus/scplus_obj.pkl', 'rb') as scplus_obj:
----> 3 data = pickle.load(scplus_obj)
ModuleNotFoundError: No module named 'pyranges.pyranges'
我没有 python 及其包、模块、内核等方面的经验。我现在只需要读入 .pkl 文件。对我来说,这似乎是模块“pyranges”的问题。我已经尝试了迄今为止基于此找到的解决方案。
答: 暂无答案
下一个:EOFError 泡菜
评论