ipython terminal : keyboard input perturbed after plotting - python

I'm using ipython 1.1.0 (installed with macports) and matplotlib 1.3.1 with the qt4agg backend (I'm on a mac, and can't use the 'macosx' backend for other problems). I have a very frustrating problem :
I can't type normally in the ipython terminal. Sometimes it's ok, and most of the time I see what I type only a while after. If I click one the python 'rocket icon" I immediately see what's been typed in the terminal.
To me that looks like the terminal is being stuck by the event loop, is that right ? A while ago I had a similar issue and I was advised to start ipython with the --pylab option and that worked well at the time (other computer, other time...). I've tried that and nothing's changed, still having the issue.
I've tried starting ipython with --gui=qt4 too and still the same issue.
I don't have the problem if I just start ipython without any option. But as soon as I plot something : problem...
here is how I installed the thing :
sudo port install py27-ipython+notebook+parallel+pyqt4+scientific
sudo port install py27-matplotlib +qt4

So I definitely think there's a bug, either in Qt or ipython or Mac OS 10.9, but typing
defaults write org.python.python NSAppSleepDisabled -bool YES
did solve my problem. Again my ipython/matplotlib etc. has been installed with macports.
That's a workaround, but for now it is alright.
sources : here and there

Related

VS Code using Jupyter: Connecting to kernel: Python 3.6.9: Waiting for Jupyter Session to be idle

I am having trouble running my import statement in VS code Jupyter. I split them into individual cells. I find when I run
import numpy as np
the cell hangs and I get a message
Connecting to kernel: Python 3.6.9: Waiting for Jupyter Session to be idle
How do I fix this?
To solve it, I uninstalled the extension Jupyter notebook (which requires a reload), and then installed it.
This may be related to the extended version. I hope this article is helpful to you.
Alright so this one surprised me..
I was using Jupyter-like code cells "#%%" (see docs) to run jupyter notebook in VSCode. And I ran into the same issue as OP.
The error disappeared when I renamed my file, from "inspect.py" to "tmp.py".
I found my solution was to select the correct version of Python. I had 2 choices for Python 3.6.9. I chose the one called "base(Python 3.6.9)" which had a different location to "Python 3.6.9" and the base version worked. Something odd if going on here, maybe I should remove the other version?
For me, upgrading ipython to version 7.34.0 (from 7.32.0) fixed it. I'm using jedi version 0.18.1. Related
Update: this broke again for me when I upgraded my virtual environment to Python 3.8. I just upgraded my ipykernel package and now the notebook runs.

IPython console in spyder extremely slow in Anaconda

I'm trying Anaconda/Spyder after using the standard python installation/IDLE for several years. The console (and variable explorer) becomes progressively slower during each work session, with every script and interactive command that I run. Eventually it takes minutes to get a response to simple commands like print, and then it stops responding completely and I shut it down. It's pretty disruptive to my work.
Mac OSX 10.13.6
conda version : 4.5.11
conda-build version : 3.15.1
python version : 3.7.0.final.0
qt 5.9.6
spyder 3.3.1
ipython 7.1.1
I do use matplotlib frequently. Whenever possible I use plt.ioff() at the beginning of a script and/or plt.close('all') at the end. Turning off matplotlib support completely in preferences doesn't help and it's not a permanent fix anyway. Python is not using anywhere near all my CPU or RAM.
As far as I've found out, the problem seems to be with the latest major release of the ipython kernel. Pinning the version of ipykernel to 4.10.0 solved it for me. To do so, add a line containing ipykernel 4.* to the file ~/anaconda3/conda-meta/pinned. Create the file if it does not exist yet. Then conda update ipykernel which will actually downgrade to 4.10.0. Worked for me!
you don't need to downgrade the entire spyder.
For me it worked with downgrading these two:
conda install ipython=6.4.0
conda install ipykernel=4.10.0
So this is not a totally satisfying solution but it seems to be a reasonable temporary fix. If you downgrade your spyder version to 3.1.X you will be able to use the python console rather than the Ipython console, and this seems to work for me. To do this just run:
conda install spyder=3.1
in the terminal while your environment of choice is active. This is not ideal, because the developers removed the python console for a specific reason as mentioned in this question, How to add python console in spyder.
Additionally downgrading this much may have unforeseen effects on other packages your code uses and may cause other issues but so far this is the only solution I was able to come up with.
#Sjoerd Thanks for your answer, this is what worked for me. To be still clearer, here's what I did in terminal on Anaconda 3 on High Sierra:
echo "ipykernel 4.10.0" >> ~/anaconda3/conda-meta/pinned
conda update anaconda
When I tried to update only ipykernel, I would have dependencies errors. By updating anaconda, everything is now up to date but ipykernel which is effectively at version 4.10.0. I didn't experience any hang since then.
#JJR4's answer didn't work for me (seems to work for others). Another workaround is to type %connect_info magic command into the IPython Spyder console which will display the JSON info to connect another console to the kernel.
The output of the magic command explains how to connect, but basically there are three options.
Paste the above JSON into a file, and connect with:
$> jupyter <app> --existing <file>
or, if you are local, you can connect with just:
$> jupyter <app> --existing <kernel>.json
or even just:
$> jupyter <app> --existing
if this is the most recent Jupyter kernel you have started.
I typically use qtconsole as the app. Once you enter your chosen connection method into the command line, a new console will open that is connected to the same kernel as the console in Spyder. For some reason, the new console does not lag even if the Spyder console does.
Enter everything in the new console, even runfile()
Hope this helps!
UPDATE:
Downgrading to ipykernel version 4.10 seems to solve the issue for me. Thanks to Carlos Cordoba - see GitHub conversation in link below.

Interface is messed up after installing several plugins | Signal only works in main thread - Spyder report

I'm trying to install several plug-ins in Spyder IDE, such as:
unit test
notebook
line profiler
spyder-terminal
memory-profiler
spyder-report
But unfortunately, I've got some serious problem. The installation was good, though I couldn't install spyder-vim and conda-manager plug-in for some unknown reason.
But the thing was horrible after launching the IDE. It's just broken somehow and not responding. Mouse unclickable. The interface was totally messed up.
After removal of these plug-ins, I again manually installed those plug-ins and tried to figure it out which plug-in caused this.
This time I only installed
unit test spyder-report notebook terminal
and now after launching, I saw interface was a little bit finer than before and discovered some problem in the spyder-report plug-in. While rendering report to HTML it showed the following error:
signal only works in main thread
I'm not sure whether I'll try other plug-in, but everything is pretty OK now except the spyder-report plug-in. I googled it for a day, but I found no effective solution.
You didn't say which version of Spyder and Python you installed, nor which operating system you are using. So, using Debian unstable and Python 3.6.5, I installed:
spyder3, 3.2.6
spyder-common, 3.2.6
python3-spyder, 3.2.6
python3-spyder-memory-profiler, 0.1.2
python3-spyder-line-profiler, 0.1.1
python3-spyder-reports, 0.1.1
python3-spyder-unittest, 0.3.0
as well as all of their dependencies. After that, I started spyder3 without any problems (except that I have to use the Spyder 2 icon theme, because it can't find the Spyder 3 icons). The Reports tab works fine, no "Signal only..." error.
The problem with spyder-vim seems to be that no actual release has been made yet, so pip3 install spyder-vim doesn't find anything.
Last, I added the terminal plugin with pip3 install spyder-terminal.
Again, after that all is working fine.

IPython notebook: auto-completion doesn't work after dot operators

I'm novice at IPython and I've got a problem with autocompletion.
Tab autocompletion doesn't work properly.
It works after imports:
import<tab>
But tab completion doesn't work after dot operators. As example:
import numpy as np
np.<tab>
Meanwhile this example works well for IPython at console.
Package pyreadline is up-to-date. I tried different browsers. I reinstalled IPython and pyreadlines. But it didn't helped.
If you write things in the same cell, it's perfectly normal. Until you've run the import line, np is not defined.
Run the cell once, or run the import statement in a previous cell and autocomplete should work.
Found the solution in an answer I found on the web:
"I've just installed the latest JEDI then helped me to solve that issue, here's the command when using Anaconda":
conda install - c anaconda jedi
"Or you might need to try this, copy this line on the top of your jupyter notebook":
% config Completer.use_jedi = False
"In my case I installed miniconda on Debian Linux and most likely had a problem with the previous Python that was included with Debian. The following lines solved my problem":
conda update conda
conda update--all

ipython (version 3.2.1) support in LightTable (version 0.7.2)

I've just started using Light Table and can't get iPython working under OSX 10.10. Relevant version numbers are iPython 3.2.1, Python 3.4.3 or 2.7.10, and LightTable version 0.7.2 (installed via a Homebrew Cask and .zip file).
Evaluating Python code works as I'd expect and I get nice tab-completion, but I can't get any graphical output. The "Connection Bar" shows a python connection rather than ipython even though ipython is available on the command line and I can successfully run ipython notebook and have it pop up a web-browser (this requires a working copy of pyzmq).
Neither Python 2.7 nor 3.4 work, and I've tried the official LT .zip as well as installing as brew cask install lighttable.
Changing my User.behaviours to explicitly reference the "correct" virtualenv:
[:app :lt.plugins.python/python-exe "/Users/smason/.virtualenvs/py3/bin/python"]
[:app :lt.plugins.python/ipython-exe "/Users/smason/.virtualenvs/py3/bin/ipython"]
doesn't seem to affect things (verified by getting appropriate errors when misspelling binary, and by running print(sys.version) and looking at output in console).
The problem was that iPython support with Light Table is pretty out of date. It is using features that were exposed in pre-1.0 versions of iPython and it's not been updated while iPython's API has changed.
The most minimal change to Light Table that fixed this for me is in:
https://github.com/LightTable/Python/pull/31
If you're patching your own install you would want to modify:
LightTable.app/Contents/Resources/app.nw/plugins/python/py-src/ltipy.py
but with iPython 4 being released yesterday more code needs to change—hopefully (if you're reading this) I'll get around to making this larger change.

Categories