Python console freeze
Hi all,
os:
windows 10
python 3.6.8
pycharm 2018.3.2 X64
This problem is related to REPL Communication, I tried to run a short script and got the following error:
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.2\helpers\pydev\_pydev_comm\server.py", line 34, in handle
self.processor.process(iprot, oprot)
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.2\helpers\third_party\thriftpy\_shaded_thriftpy\thrift.py", line 266, in process
self.handle_exception(e, result)
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.2\helpers\third_party\thriftpy\_shaded_thriftpy\thrift.py", line 254, in handle_exception
raise e
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.2\helpers\third_party\thriftpy\_shaded_thriftpy\thrift.py", line 263, in process
result.success = call()
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.2\helpers\third_party\thriftpy\_shaded_thriftpy\thrift.py", line 228, in call
return f(*(args.__dict__[k] for k in api_args))
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.2\helpers\pydev\_pydev_bundle\pydev_console_utils.py", line 236, in getArray
return pydevd_thrift.table_like_struct_to_thrift_struct(array, name, roffset, coffset, rows, cols, format)
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.2\helpers\pydev\_pydevd_bundle\pydevd_thrift.py", line 588, in table_like_struct_to_thrift_struct
return TYPE_TO_THRIFT_STRUCT_CONVERTERS[type_name](array, name, roffset, coffset, rows, cols, format)
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.2\helpers\pydev\_pydevd_bundle\pydevd_thrift.py", line 533, in dataframe_to_thrift_struct
lambda r: (("%" + col_to_format(c)) % (df.iat[r, c] if dim > 1 else df.iat[r])
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.2\helpers\pydev\_pydevd_bundle\pydevd_thrift.py", line 545, in array_data_to_thrift_struct
data.append([var_to_str(value) for value in get_row(row)])
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.2\helpers\pydev\_pydevd_bundle\pydevd_thrift.py", line 545, in <listcomp>
data.append([var_to_str(value) for value in get_row(row)])
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.2\helpers\pydev\_pydevd_bundle\pydevd_thrift.py", line 534, in <genexpr>
for c in range(cols)))
File "C:\Users\Aviv\PycharmProjects\project\venv\lib\site-packages\pandas\core\indexing.py", line 2142, in __getitem__
return self.obj._get_value(*key, takeable=self._takeable)
File "C:\Users\Aviv\PycharmProjects\project\venv\lib\site-packages\pandas\core\frame.py", line 2532, in _get_value
series = self._iget_item_cache(col)
File "C:\Users\Aviv\PycharmProjects\project\venv\lib\site-packages\pandas\core\generic.py", line 2515, in _iget_item_cache
lower = self._take(item, axis=self._info_axis_number)
File "C:\Users\Aviv\PycharmProjects\project\venv\lib\site-packages\pandas\core\generic.py", line 2789, in _take
verify=True)
File "C:\Users\Aviv\PycharmProjects\project\venv\lib\site-packages\pandas\core\internals.py", line 4539, in take
axis=axis, allow_dups=True)
File "C:\Users\Aviv\PycharmProjects\project\venv\lib\site-packages\pandas\core\internals.py", line 4421, in reindex_indexer
fill_tuple=(fill_value,))
File "C:\Users\Aviv\PycharmProjects\project\venv\lib\site-packages\pandas\core\internals.py", line 4446, in _slice_take_blocks_ax0
slice_or_indexer, self.shape[0], allow_fill=allow_fill)
File "C:\Users\Aviv\PycharmProjects\project\venv\lib\site-packages\pandas\core\internals.py", line 5902, in _preprocess_slice_or_indexer
return 'fancy', indexer, len(indexer)
TypeError: len() of unsized object
afterwards the python console froze and it looks like the REPL Communication is running without stopping.
What is exactly the meaning of REPL and how can I fix this bug?
BR,
Aviv
Please sign in to leave a comment.
Hi!
Instead of trying to explain REPL myself, I'll better link to Wikipedia: https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop
Don't worry, it's nothing fancy. Your error, however, seems to be caused entirely by the code, not IDE. I would assume that len() cannot be used on the object of this type.
Please refer to https://docs.python.org/3/library/exceptions.html and search for "TypeError".
I assume too that is a problem with my code but I don't think it's so crucial that the python console should crash.
Can't I do something about it?
Oh, sorry, I seemed to miss the part about console freezing. Can you provide a script sample necessary to reproduce the issue?
The problem occurs when I try to view DataFrame variable.
I think I know what the problem is when DataFrame variable (father) has a field which is DataFrame type (child) and I try to view the father the console freezes.
Try to reproduce it that way and see what happens, in my case the console freezes.
BR,
Aviv Shamsian
Still, can you provide the minimal code snippet necessary to reproduce the issue? To ensure we're not talking about different things.
Hi Andrey,
Sorry for the late response, try to use the following lines of code:
a = pd.DataFrame([ i for i in range(10)])
b = pd.Series([ i for i in range(10)])
c = pd.concat((a,b), axis = 1)
now try and click on view as DataFrame for c (I know that its an error but I don't think it should freeze the console).
BR,
Aviv Shamsian
Thank you for the information, I've reproduced this behavior and created a corresponding bug report, please follow it here: https://youtrack.jetbrains.com/issue/PY-33973
You are welcome to comment and vote.
Thank you Andery.
What are your thoughts? do you think it's a bug on my environment? or a general bug?
Sorry, it seems I was wrong assuming the issue is caused by the error in the code.
This seems indeed like an IDE bug, but I'm not sure in which sub-system - console, or our implementation of DataFrame viewer. Let's see comments from the developer.
Interesting...
Hi Aviv,
We made a custom build with the issue fixed, you can download it here:
https://drive.google.com/a/jetbrains.com/uc?id=1tCSopdDLyDHGOYpECwsJBQ7y7zJBsSyphttp://bit.ly/2V75REF
Please note that we recommend using this built only if the issue is critical for you. If it's not, we recommend waiting for a stable release where this fix will be included (in upcoming version 2019.1)
Something bad happened to PyCharm in recent version. I experience this hangs almost every day on Mac. PyCharm becomes unresponsive and only Force Quits.
A simple code with yield. Current project is using Jupyter notebook.
Please report it to https://youtrack.jetbrains.com/issues/PY providing steps for reproducing the problem and your logs folder zipped from Help | Collect Logs and Diagnostic Data.
Hi Jevengi, I am also experiencing a similar problem. My python console hangs the command after importing numpy, did you report the issue?
Support asked to try 2020.2 EAP, which solved the problem. Great thanks to them.