Python之Anaconda启动过程中的异常错误问题及解决

 更新时间:2023年09月07日 14:49:51   作者:bladestone  
这篇文章主要介绍了Python之Anaconda启动过程中的异常错误问题及解决方案,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教

Anaconda

一个非常优秀的python发行版本。

问题的提出

某天,忽然发现,启动spyder之后,一直在Connecting to Kernel, Loading起来没完没了,本质上就是连接不上了。

启动IPython之时,报出如下的错误信息:

ERROR:tornado.general:Uncaught exception in ZMQStream callback
Traceback (most recent call last):
File "d:\ProgramData\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 432, in _run_callback
callback(*args, **kwargs)
File "d:\ProgramData\Anaconda3\lib\site-packages\tornado\stack_context.py", line 277, in null_wrapper
return fn(*args, **kwargs)
File "d:\ProgramData\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 283, in dispatcher
return self.dispatch_shell(stream, msg)
File "d:\ProgramData\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 233, in dispatch_shell
self.pre_handler_hook()
File "d:\ProgramData\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 248, in pre_handler_hook
self.saved_sigint_handler = signal(SIGINT, default_int_handler)
File "d:\ProgramData\Anaconda3\lib\signal.py", line 47, in signal
handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread
ERROR:tornado.general:Uncaught exception in zmqstream callback
Traceback (most recent call last):
File "d:\ProgramData\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 450, in _handle_events
self._handle_recv()
File "d:\ProgramData\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 480, in _handle_recv
self._run_callback(callback, msg)
File "d:\ProgramData\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 432, in _run_callback
callback(*args, **kwargs)
File "d:\ProgramData\Anaconda3\lib\site-packages\tornado\stack_context.py", line 277, in null_wrapper
return fn(*args, **kwargs)
File "d:\ProgramData\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 283, in dispatcher
return self.dispatch_shell(stream, msg)
File "d:\ProgramData\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 233, in dispatch_shell
self.pre_handler_hook()
File "d:\ProgramData\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 248, in pre_handler_hook
self.saved_sigint_handler = signal(SIGINT, default_int_handler)
File "d:\ProgramData\Anaconda3\lib\signal.py", line 47, in signal
handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread
ERROR:tornado.application:Exception in callback functools.partial(.null_wrapper at 0x0000000005B33488>)
Traceback (most recent call last):
File "d:\ProgramData\Anaconda3\lib\site-packages\tornado\ioloop.py", line 605, in _run_callback
ret = callback()
File "d:\ProgramData\Anaconda3\lib\site-packages\tornado\stack_context.py", line 277, in null_wrapper
return fn(*args, **kwargs)
File "d:\ProgramData\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 536, in 
self.io_loop.add_callback(lambda : self._handle_events(self.socket, 0))
File "d:\ProgramData\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 450, in _handle_events
self._handle_recv()
File "d:\ProgramData\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 480, in _handle_recv
self._run_callback(callback, msg)
File "d:\ProgramData\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 432, in _run_callback
callback(*args, **kwargs)
File "d:\ProgramData\Anaconda3\lib\site-packages\tornado\stack_context.py", line 277, in null_wrapper
return fn(*args, **kwargs)
File "d:\ProgramData\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 283, in dispatcher
return self.dispatch_shell(stream, msg)
File "d:\ProgramData\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 233, in dispatch_shell
self.pre_handler_hook()
File "d:\ProgramData\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 248, in pre_handler_hook
self.saved_sigint_handler = signal(SIGINT, default_int_handler)
File "d:\ProgramData\Anaconda3\lib\signal.py", line 47, in signal
handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread

从错误信息来看,肯定是某个包的版本冲突导致的问题。

问题的解决

从网络上,找了一番之后,决定如下尝试:

conda uninstall jupyter tornado
Solving environment: done
==> WARNING: A newer version of conda exists. <==
  current version: 4.4.6
  latest version: 4.5.9
Please update conda by running
    $ conda update -n base conda
## Package Plan ##
  environment location: D:\ProgramData\Anaconda3
  removed specs:
    - jupyter
    - tornado
The following packages will be REMOVED:
    anaconda-project: 0.8.0-py36h8b3bf89_0
    jupyter:          1.0.0-py36h422fd7e_2
    jupyter_console:  5.2.0-py36h6d89b47_1
    seaborn:          0.8.0-py36h62cb67c_0
    tornado:          4.5.3-py36_0
Proceed ([y]/n)? y
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

在卸载之后,重新安装:

conda install jupyter tornado

安装过程中的信息输出如下:

Solving environment: done
==> WARNING: A newer version of conda exists. <==
  current version: 4.4.6
  latest version: 4.5.9
Please update conda by running
    $ conda update -n base conda
## Package Plan ##
  environment location: D:\ProgramData\Anaconda3
  added / updated specs:
    - jupyter
    - tornado
The following packages will be downloaded:
    package                    |            build
    ---------------------------|-----------------
    ipykernel-4.8.2            |           py36_0         146 KB
    ipywidgets-7.4.0           |           py36_0         150 KB
    jupyter_client-5.2.3       |           py36_0         188 KB
    nbconvert-5.3.1            |           py36_0         422 KB
    widgetsnbextension-3.4.0   |           py36_0         1.7 MB
    tornado-5.1                |   py36hfa6e2cd_0         669 KB
    jupyter-1.0.0              |           py36_5           6 KB
    jupyter_console-5.2.0      |           py36_1          53 KB
    ------------------------------------------------------------
                                           Total:         3.3 MB
The following NEW packages will be INSTALLED:
    jupyter:            1.0.0-py36_5
    jupyter_console:    5.2.0-py36_1
    tornado:            5.1-py36hfa6e2cd_0
The following packages will be UPDATED:
    ipykernel:          4.6.1-py36hbb77b34_0 --> 4.8.2-py36_0
    ipywidgets:         7.0.0-py36h2e74ada_0 --> 7.4.0-py36_0
    jupyter_client:     5.2.2-py36_0         --> 5.2.3-py36_0
    nbconvert:          5.3.1-py36h8dc0fde_0 --> 5.3.1-py36_0
    widgetsnbextension: 3.0.2-py36h364476f_1 --> 3.4.0-py36_0
Proceed ([y]/n)? y
Downloading and Extracting Packages
ipykernel 4.8.2: ################################################################
ipywidgets 7.4.0: ###############################################################
jupyter_client 5.2.3: ###########################################################
nbconvert 5.3.1: ################################################################
widgetsnbextension 3.4.0: #######################################################
tornado 5.1: ####################################################################
jupyter 1.0.0: ##################################################################
jupyter_console 5.2.0: ##########################################################
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

总结

常从河边走,偶尔会湿鞋,这些工具偶尔也会报错的,出了问题,就尝试解决就好了。

好了,以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

相关文章

  • Python面向对象实现一个对象调用另一个对象操作示例

    Python面向对象实现一个对象调用另一个对象操作示例

    这篇文章主要介绍了Python面向对象实现一个对象调用另一个对象操作,结合实例形式分析了Python对象的定义、初始化、调用等相关操作技巧,需要的朋友可以参考下
    2019-04-04
  • 关于Python中object类特殊方法的解释

    关于Python中object类特殊方法的解释

    在学习Python的过程中我们会发现有一个类 Object类 ,它是所有类的父类,Object类规定了python用于类的内置函数,今天我们就来看看几个常用的特殊方法吧
    2023-03-03
  • Python3 实现减少可调用对象的参数个数

    Python3 实现减少可调用对象的参数个数

    今天小编就为大家分享一篇Python3 实现减少可调用对象的参数个数,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2019-12-12
  • 在python中利用GDAL对tif文件进行读写的方法

    在python中利用GDAL对tif文件进行读写的方法

    今天小编就为大家分享一篇在python中利用GDAL对tif文件进行读写的方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2018-11-11
  • pycharm远程linux开发和调试代码的方法

    pycharm远程linux开发和调试代码的方法

    这篇文章主要介绍了pycharm远程linux开发和调试代码的方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2018-07-07
  • 用python实现PDF解密打印文件

    用python实现PDF解密打印文件

    大家好,本篇文章主要讲的是用python实现PDF解密打印文件,感兴趣的同学赶快来看一看吧,对你有帮助的话记得收藏一下
    2022-02-02
  • python 使用GDAL实现栅格tif转矢量shp的方式小结

    python 使用GDAL实现栅格tif转矢量shp的方式小结

    今天通过本文给大家分享python 使用GDAL实现栅格tif转矢量shp的方式小结,计划是使用栅格转矢量的方式,将栅格数据转为矢量shp文件,然后进行矢量切片,使用Mapbox进行前端动态渲染,具体内容详情跟随小编一起看看吧
    2021-08-08
  • PyautoGui常用教程(一篇掌握)

    PyautoGui常用教程(一篇掌握)

    这篇文章主要介绍了PyautoGui常用教程(一篇掌握),文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2021-04-04
  • python3实现高效的端口扫描

    python3实现高效的端口扫描

    这篇文章主要为大家详细介绍了python3实现高效的端口扫描,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2019-08-08
  • pandas dataframe rolling移动计算方式

    pandas dataframe rolling移动计算方式

    在Pandas中,rolling()方法用于执行移动窗口计算,常用于时间序列数据分析,例如,计算某商品的7天或1个月销售总量,可以通过rolling()轻松实现,该方法的关键参数包括window(窗口大小),min_periods(最小计算周期)
    2024-09-09

最新评论