I am using Pycharm
2016.1
on CentOS7
and I am testing "Show command line afterwards
" and I got this Problem:
AttributeError: 'PyDevTerminalInteractiveShell' object has no attribute 'has_readline'
/usr/bin/python3.4 /usr/local/pycharm/helpers/pydev/pydev_run_in_console.py 37196 52554 /root/PycharmProjects/mytf/mytest/test5.py Traceback (most recent call last): File "/usr/local/pycharm/helpers/pydev/pydev_run_in_console.py", line 63, in <module> interpreter = InterpreterInterface(host, int(client_port), threading.currentThread()) File "/usr/local/pycharm/helpers/pydev/_pydev_bundle/pydev_ipython_console.py", line 26, in __init__ self.interpreter = get_pydev_frontend(host, client_port, show_banner=show_banner) File "/usr/local/pycharm/helpers/pydev/_pydev_bundle/pydev_ipython_console_011.py", line 473, in get_pydev_frontend _PyDevFrontEndContainer._instance = _PyDevFrontEnd(show_banner=show_banner) File "/usr/local/pycharm/helpers/pydev/_pydev_bundle/pydev_ipython_console_011.py", line 303, in __init__ self.ipython = PyDevTerminalInteractiveShell.instance() File "/usr/lib/python3.4/site-packages/traitlets/config/configurable.py", line 412, in instance inst = cls(*args, **kwargs) File "/usr/lib/python3.4/site-packages/IPython/terminal/interactiveshell.py", line 359, in __init__ super(TerminalInteractiveShell, self).__init__(*args, **kwargs) File "/usr/lib/python3.4/site-packages/IPython/core/interactiveshell.py", line 487, in __init__ self.init_completer() File "/usr/local/pycharm/helpers/pydev/_pydev_bundle/pydev_ipython_console_011.py", line 222, in init_completer self.Completer = self._new_completer_200() File "/usr/local/pycharm/helpers/pydev/_pydev_bundle/pydev_ipython_console_011.py", line 194, in _new_completer_200 use_readline=self.has_readline, AttributeError: 'PyDevTerminalInteractiveShell' object has no attribute 'has_readline'
Attributes are functions or properties associated with an object of a class. Everything in Python is an object, and all these objects have a class with some attributes. We can access such properties using the . operator. This tutorial will discuss the object has no attribute python error in Python. This error belongs to the AttributeError type.
This error belongs to the AttributeError type. We encounter this error when trying to access an object’s unavailable attribute. For example, the NumPy arrays in Python have an attribute called size that returns the size of the array.
The dir () function can be used to view all the associated attributes of an object. However, this method may miss attributes inherited via a metaclass. We can also update our object to the type that supports the required attribute. However, this is not a good method and may lead to other unwanted errors.
You're trying to apply readlines to a list. In your example, data is already a list which contains the file lines. The line: is redundant. You can remove it. More, bear with the fact that the method readlines () reads until EOF using readline () and already returns a list containing the lines. with open (some_file) as f: ....
This PyCharm issue occurs because of changes the the iPython
api with iPython
version 5. Until Jetbrains fix this, reverting to an earlier version of iPython
(version 4) will correct this. As @chenfei has discovered, this can be done through pip
:
$ pip uninstall ipython $ pip install ipython==4.2.0
Edit
And if you can't wait that long, Jetbrains have released a patch
https://youtrack.jetbrains.com/issue/PY-20013#comment=27-1512407
Final Edit
This issue has been fixed in PyCharm 2016.2
I solved my problem via installing ipython version 4.2:
pip uninstall ipython pip install ipython==4.2.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With