Tag Archives: Error analysis

Solution to abnormal errors during startup of Python’s Anaconda

Anaconda
A very good Python distribution.
Question raising
One day, suddenly found that after starting Spyder, has been in Connecting to Kernel, Loading endless, in essence is not connected.
when IPython is started, the following error message is reported:

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

Judging from the error message, it must be a version conflict for one of the packages.
Problem solving
After searching the Internet, I decided to try the following:

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

After uninstalling, reinstall:

conda install jupyter tornado

The information output during installation is as follows:

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

conclusion
Often walk from the river, occasionally wet shoes, these tools will occasionally report errors, if there is a problem, just try to solve it.

Analysis of R language error replacement has length zero problem

I encountered this problem before when I was doing a for loop, where the second layer of the loop is , ncol=3, so here the loop is going to be for(j in 1:2) and then the assignment matrix is the following error.

After
, it was found on the Internet that the error was caused by improper alignment of array or matrix or out-of-bounds subscripts. After checking the code, it was found that there was indeed a small error, that is, for(j in 1:ncol-1) is equivalent to for(j in 0:1). Obviously, an error will be reported when assigning the value. for(j in 1: ncol-1)) correct.