在zmq lib import上解决Anaconda / iPython笔记本/ Spyder IDE启动失败?

时间:2015-03-12 21:34:11

标签: python ide ipython-notebook anaconda spyder

这是在Windows 7 - 64,python 2.7.8上安装的全新Anaconda 2.1。 Spyder IDE无法启动,并在从cli运行python spyder --reset时抛出相同的错误/写入相同的回溯。查看回溯,加载zmq模块似乎存在问题。该模块\__init__.py会查找包含以下其中一个exts的任何预编译libzmq文件:pydsodlldylib,并添加它们列出bundled,然后尝试加载bundled[0]

bundled = []
bundled_sodium = []
for ext in ('pyd', 'so', 'dll', 'dylib'):
    bundled_sodium.extend(glob.glob(os.path.join(here, 'libsodium*.%s*' % ext)))
    bundled.extend(glob.glob(os.path.join(here, 'libzmq*.%s*' % ext)))

令人困惑的是libzmq.pyd位于Anaconda2.1\Lib\site-packages\zmq目录中!在查看代码和SO上的其他问题后,我很难过。请帮忙。

回溯:

C:\Users\someUser>cmd /K spyder
    Traceback (most recent call last):
      File "C:\Users\someUser\Anaconda2.1\Scripts\spyder-script.py", line 2, in <m
    odule>
        start_app.main()
      File "C:\Users\someUser\Anaconda2.1\lib\site-packages\spyderlib\start_app.py
    ", line 85, in main
        from spyderlib import spyder
      File "C:\Users\someUser\Anaconda2.1\lib\site-packages\spyderlib\spyder.py",
    line 45, in <module>
        from spyderlib.ipythonconfig import IPYTHON_QT_INSTALLED, SUPPORTED_IPYTHON
      File "C:\Users\someUser\Anaconda2.1\lib\site-packages\spyderlib\ipythonconfi
    g.py", line 22, in <module>
        IPYTHON_QT_INSTALLED = is_qtconsole_installed()
      File "C:\Users\someUser\Anaconda2.1\lib\site-packages\spyderlib\ipythonconfi
    g.py", line 15, in is_qtconsole_installed
        pyzmq_installed = programs.is_module_installed('zmq')
      File "C:\Users\someUser\Anaconda2.1\lib\site-packages\spyderlib\utils\progra
    ms.py", line 272, in is_module_installed
        actver = get_module_version(module_name)
      File "C:\Users\someUser\Anaconda2.1\lib\site-packages\spyderlib\utils\progra
    ms.py", line 218, in get_module_version
        mod = __import__(module_name)
      File "C:\Python27\Lib\site-packages\zmq\__init__.py", line 41, in <module>
        _libzmq = ctypes.cdll.LoadLibrary(bundled[0])
      File "C:\Users\someUser\Anaconda2.1\lib\ctypes\__init__.py", line 443, in Lo
    adLibrary
        return self._dlltype(name)
      File "C:\Users\someUser\Anaconda2.1\lib\ctypes\__init__.py", line 365, in __
    init__
        self._handle = _dlopen(self._name, mode)
    WindowsError: [Error 193] %1 is not a valid Win32 application

    C:\Users\someUser>spyder --reset
    Traceback (most recent call last):
      File "C:\Users\someUser\Anaconda2.1\Scripts\spyder-script.py", line 2, in <m
    odule>
        start_app.main()
      File "C:\Users\someUser\Anaconda2.1\lib\site-packages\spyderlib\start_app.py
    ", line 85, in main
        from spyderlib import spyder
      File "C:\Users\someUser\Anaconda2.1\lib\site-packages\spyderlib\spyder.py",
    line 45, in <module>
        from spyderlib.ipythonconfig import IPYTHON_QT_INSTALLED, SUPPORTED_IPYTHON
      File "C:\Users\someUser\Anaconda2.1\lib\site-packages\spyderlib\ipythonconfi
    g.py", line 22, in <module>
        IPYTHON_QT_INSTALLED = is_qtconsole_installed()
      File "C:\Users\someUser\Anaconda2.1\lib\site-packages\spyderlib\ipythonconfi
    g.py", line 15, in is_qtconsole_installed
        pyzmq_installed = programs.is_module_installed('zmq')
      File "C:\Users\someUser\Anaconda2.1\lib\site-packages\spyderlib\utils\progra
    ms.py", line 272, in is_module_installed
        actver = get_module_version(module_name)
      File "C:\Users\someUser\Anaconda2.1\lib\site-packages\spyderlib\utils\progra
    ms.py", line 218, in get_module_version
        mod = __import__(module_name)
      File "C:\Python27\Lib\site-packages\zmq\__init__.py", line 41, in <module>
        _libzmq = ctypes.cdll.LoadLibrary(bundled[0])
      File "C:\Users\someUser\Anaconda2.1\lib\ctypes\__init__.py", line 443, in Lo
    adLibrary
        return self._dlltype(name)
      File "C:\Users\someUser\Anaconda2.1\lib\ctypes\__init__.py", line 365, in __
    init__
        self._handle = _dlopen(self._name, mode)
    WindowsError: [Error 193] %1 is not a valid Win32 application

编辑:此问题也阻止了iPython笔记本电脑的开放。追溯中的相同错误:

Traceback (most recent call last):
  File "C:\Users\eric.adams\Anaconda2.1\Scripts/ipython-script.py", line 5, in <
module>
    sys.exit(start_ipython())
  File "C:\Python27\Lib\site-packages\IPython\__init__.py", line 120, in start_i
python
    return launch_new_instance(argv=argv, **kwargs)
  File "C:\Python27\Lib\site-packages\IPython\config\application.py", line 563,
in launch_instance
    app.initialize(argv)
  File "<string>", line 2, in initialize
  File "C:\Python27\Lib\site-packages\IPython\config\application.py", line 92, i
n catch_config_error
    return method(app, *args, **kwargs)
  File "C:\Python27\Lib\site-packages\IPython\terminal\ipapp.py", line 321, in i
nitialize
    super(TerminalIPythonApp, self).initialize(argv)
  File "<string>", line 2, in initialize
  File "C:\Python27\Lib\site-packages\IPython\config\application.py", line 92, i
n catch_config_error
    return method(app, *args, **kwargs)
  File "C:\Python27\Lib\site-packages\IPython\core\application.py", line 381, in
 initialize
    self.parse_command_line(argv)
  File "C:\Python27\Lib\site-packages\IPython\terminal\ipapp.py", line 316, in p
arse_command_line
    return super(TerminalIPythonApp, self).parse_command_line(argv)
  File "<string>", line 2, in parse_command_line
  File "C:\Python27\Lib\site-packages\IPython\config\application.py", line 92, i
n catch_config_error
    return method(app, *args, **kwargs)
  File "C:\Python27\Lib\site-packages\IPython\config\application.py", line 475,
in parse_command_line
    return self.initialize_subcommand(subc, subargv)
  File "<string>", line 2, in initialize_subcommand
  File "C:\Python27\Lib\site-packages\IPython\config\application.py", line 92, i
n catch_config_error
    return method(app, *args, **kwargs)
  File "C:\Python27\Lib\site-packages\IPython\config\application.py", line 406,
in initialize_subcommand
    subapp = import_item(subapp)
  File "C:\Python27\Lib\site-packages\IPython\utils\importstring.py", line 42, i
n import_item
    module = __import__(package, fromlist=[obj])
  File "C:\Python27\Lib\site-packages\IPython\html\notebookapp.py", line 39, in
<module>
    check_for_zmq('2.1.11', 'IPython.html')
  File "C:\Python27\Lib\site-packages\IPython\utils\zmqrelated.py", line 35, in
check_for_zmq
    import zmq
  File "C:\Python27\Lib\site-packages\zmq\__init__.py", line 41, in <module>
    _libzmq = ctypes.cdll.LoadLibrary(bundled[0])
  File "C:\Users\eric.adams\Anaconda2.1\lib\ctypes\__init__.py", line 443, in Lo
adLibrary
    return self._dlltype(name)
  File "C:\Users\eric.adams\Anaconda2.1\lib\ctypes\__init__.py", line 365, in __
init__
    self._handle = _dlopen(self._name, mode)
WindowsError: [Error 193] %1 is not a valid Win32 application

1 个答案:

答案 0 :(得分:1)

你正在以某种方式在C:\Python27中安装Python。您是否设置了PYTHONPATH环境变量?如果是这样,请取消设置。

最简单的解决方案是删除或留出C:\Python27