一直在通过PythonXY使用Spyder,今天它停止了工作。我似乎能够启动PythonXY程序文件夹中的其他功能(例如,Mayavi、Ipython控制台等),但PythonXY或Spyder都不会正常启动。当我从命令行启动它们时,我会得到以下错误跟踪。关于如何解决这个问题(已经尝试过卸载和重新安装pythonxy/python),有什么建议吗?
Traceback (most recent call last):
File "C:\Python27\Scripts\xyhome.pyw", line 20, in <module>
from xy import xyhome
File "C:\Python27\lib\site-packages\xy\xyhome.pyw", line 60, in <module>
from xy.config import (CONF, STARTUP_PATH, LOG_PATH, PLUGINS, XY_VERSION,
File "C:\Python27\lib\site-packages\xy\config.py", line 40, in <module>
CONF = UserConfig('xy', defaults=DEFAULTS, version=__version__, subfolder='.
xy')
File "C:\Python27\lib\site-packages\xy\userconfig.py", line 110, in __init__
if version != self.get_version(version):
File "C:\Python27\lib\site-packages\xy\userconfig.py", line 130, in get_versio
n
return self.get(self.DEFAULT_SECTION_NAME, 'version', version)
File "C:\Python27\lib\site-packages\xy\userconfig.py", line 266, in get
self.set(section, option, default)
File "C:\Python27\lib\site-packages\xy\userconfig.py", line 332, in set
self.__save()
File "C:\Python27\lib\site-packages\xy\userconfig.py", line 167, in __save
self.write(conf_file)
File "C:\Python27\lib\ConfigParser.py", line 407, in write
fp.write("[%s]\n" % section)
TypeError: must be unicode, not str
>>>当我从上一次conf_file调用中打印出userconfig.py时,参数看起来确实是unicode:
<_io.TextIOWrapper name=u'C:\\Users\\rclement\\.xy\\.xy.ini' encoding='utf-8'>我能够通过删除C:\Python27 27目录和非pythonxy安装包留下的相关子目录来重新安装。没有进行注册表更改,Windows环境路径设置与我设置的设置相同。我仍然不知道问题的原因。
发布于 2016-05-26 06:39:00
我对这个错误做了快速修复。
for section in self._sections:
fp.write("[%s]\n" % unicode(section)) #forced conversion to unicode
for (key, value) in self._sections[section].items():
if key == "__name__":
continue
if (value is not None) or (self._optcre == self.OPTCRE):
key = " = ".join((key, str(value).replace('\n', '\n\t')))
fp.write("%s\n" % (unicode(key))) #forced conversion to unicode
fp.write(u"\n") #forced conversion to unicode这个快速解决方案对我有效。但不知道是什么导致了这个问题。:-(
https://stackoverflow.com/questions/33862268
复制相似问题