gpt4 book ai didi

python - 解决 zmq lib 导入时 Anaconda/iPython Notebooks/Spyder IDE 启动失败的问题?

转载 作者:太空宇宙 更新时间:2023-11-03 17:51:34 25 4
gpt4 key购买 nike

这是在 Windows 7 - 64、python 2.7.8 上全新安装的 Anaconda 2.1。从 cli 运行 python spyder --reset 时,Spyder IDE 无法启动,并引发相同的错误/写入相同的回溯。查看回溯,加载 zmq 模块似乎出现问题。该模块的 \__init__.py 查找具有以下扩展名之一的任何预编译的 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 Notebooks 打开。回溯中的相同错误:

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

最佳答案

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

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

关于python - 解决 zmq lib 导入时 Anaconda/iPython Notebooks/Spyder IDE 启动失败的问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29020635/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com