簡體   English   中英

pythonxy和spyder無法啟動-在ConfigParser.py中鍵入錯誤

[英]pythonxy and spyder fail to start — type error in ConfigParser.py

一直通過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
>>>

當我從上一個userconfig.py調用中打印出conf_file時,該參數的確顯示為unicode:

<_io.TextIOWrapper name=u'C:\\Users\\rclement\\.xy\\.xy.ini' encoding='utf-8'>

通過刪除C:\\ Python27目錄和非pythonxy已安裝程序包留下的關聯子目錄,我可以獲得重新安裝的信息。 沒有進行注冊表更改,並且保留了Windows環境PATH設置。 我仍然不知道問題的原因。

我對此錯誤進行了快速修復

    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

此快速修復對我有用。 但是不知道是什么引起了問題。 :-(

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM