0
我从python 2.7切换到python 3.3时遇到了一个问题。我用spyderlib,但现在升级到spyder。因此,我已经修改了我的代码将所有变量保存到下面一个spydata数据:使用spyder库将所有变量保存到spydata文件
from spyder.utils.iofuncs import save_dictionary
def variablesfilter():
from spyder.widgets.variableexplorer.utils import globalsfilter
from spyder.plugins.variableexplorer import VariableExplorer
from spyder.config.base import get_conf_path, get_supported_types
data = globals()
settings = VariableExplorer.get_settings()
get_supported_types()
data = globalsfilter(data,
check_all=True,
filters=tuple(get_supported_types()['picklable']),
exclude_private=settings['exclude_private'],
exclude_uppercase=settings['exclude_uppercase'],
exclude_capitalized=settings['exclude_capitalized'],
exclude_unsupported=settings['exclude_unsupported'],
excluded_names=settings['excluded_names']+['settings','In'])
return data
def saveglobals(filename):
data = variablesfilter()
save_dictionary(data,filename)
savepath = 'memory.spydata'
saveglobals(savepath)
然而,它引发我们的错误象下面这样:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\jialiang.shen\AppData\Local\Continuum\Anaconda3_new\lib\site-packages\spyder\utils\site\sitecustomize.py", line 880, in runfile
execfile(filename, namespace)
File "C:\Users\jialiang.shen\AppData\Local\Continuum\Anaconda3_new\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/jialiang.shen/temp/s1.py", line 37, in <module>
saveglobals(savepath)
File "C:/Users/jialiang.shen/temp/s1.py", line 32, in saveglobals
data = variablesfilter()
File "C:/Users/jialiang.shen/temp/s1.py", line 18, in variablesfilter
settings = VariableExplorer.get_settings()
TypeError: get_settings() missing 1 required positional argument: 'self'
这个错误应该源于图书馆spyderlib升级到spyder。任何人都可以帮助我吗?非常感谢!
我已经试过这种方法,但之后我做了这个变化蟒蛇得到坠毁。有什么想法吗? – David