本文介绍了读取“挑剔"错误.文件,没有名为“数据"的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用Anaconda Navigator读取泡菜文件,并具有以下脚本.

I tried to read pickle file using Anaconda Navigator and have the following script.

import pickle
import sys, os

with open('pickle1', 'rb') as fp:
    data_new = pickle.load(fp)

运行该窗口后,出现以下错误窗口.

After running the window I get the following error window.

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-4-047bee0f1247> in <module>()
      3
      4 with open('pickle1', 'rb') as fp:
----> 5     data_new = pickle.load(fp)

ModuleNotFoundError: No module named 'Data'

您能帮我解决此问题吗?我试图将文件重命名为* .pkl和* .csv格式,但没有帮助.原始数据文件没有自己的扩展名.

Can you please help me fix this issue? I tried to rename file to *.pkl, and *.csv formats, but it did not help. Original data file has no extension of its own.

推荐答案

创建pickle文件的程序做了import Data,并且在pickled对象中有对该模块的引用.加载腌制对象的程序需要能够导入该模块以解析那些引用.将Data.py的位置放在PYTHONPATH上(或将该位置添加到sys.path),或将模块复制到程序可以找到它的位置.

The program that created the pickle file did import Data and there are references to that module inside the pickled object. The program that loads the pickled object needs to be able to import that module to resolve those references. Either put the location of Data.py on your PYTHONPATH (or add the location to sys.path), or copy the module to where your program can find it.

这篇关于读取“挑剔"错误.文件,没有名为“数据"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 01:40