0

Let me first start by saying that this post is related to many on this site and that I am simply posting this for posterity and helping to add evidence as to why this particular error occurs.

So I have a script that I run that pulls in data to a data frame from sql, then it does some operations and writes the output back to the sql server. I first began experiencing the random "Kernel Died" error when I added the executemany() to my sqlalchemy script for writing to the server using pandas to_sql command. I could not figure this out for the life of me.

Continue down the road a bit and I began writing large amounts of information back to the server without using executemany() and was receiving the error that I had duplicate primary keys when writing to the server. I have known historically that there is a known issue in converting from pandas to h2o frames that the h2o frame will sometimes create a duplicate record in the frame. When this converts back to pandas you will still have the duplicate and when you write that back to the server you will still have the duplicate. One of the values being written back to my server is a primary key and so cannot have a duplicate entry and causes an error.

All of that being said. When I turn off executemany(), I get the error that there is a duplicate in the primary key and the operation stops. When I turn on the executemany(), I get the error that the "Kernel has Died".

So with that evidence I am proposing that the Kernel has Died error is some error in another package/entity that is not being translated back to the kernel and is causing a kernel has died error.

The question is: Where are we on these two issues? The posts I have seen are ~11 months old

Also if this post isn't allowed here where can I post information like this in order to help the developers understand the common problem?

EDIT: Follow on...

Just ran a test in jupyter with the same script. I received the appropriate error for duplicate primary key with executemany(). Just to be clear: in spyder I would have received "Kernel Died".

However i also received this error.

C:\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py in 
_execute_context(self, dialect, constructor, statement, parameters, *args)
   1169                         parameters,
-> 1170                         context)
   1171             elif not parameters and context.no_parameters:

C:\Anaconda3\lib\site-packages\sqlalchemy\engine\default.py in 
do_executemany(self, cursor, statement, parameters, context)
    503     def do_executemany(self, cursor, statement, parameters, 
context=None):
--> 504         cursor.executemany(statement, parameters)
    505

2 Answers2

0

I just found a novice solution. Copy all your project files to a new directory, set the Spyder to factory defaults, and create a new project in the new directory! Dead kernel revives!

FUNDMANAGER
  • 1
  • 1
  • 4
0

Something similar happened to me when using TensorFlow though. I fixed it by adding the following code at the start of my script

import os
os.environ['KMP_DUPLICATE_LIB_OK']='True'

It might have something to do with the kernel trying to import a module multiple times that it just crashes.

Mahmoud Gabr
  • 109
  • 2
  • 12