Restart IPython kernel - python

I am using Anaconda/Iphython 32bit on a Windows machine wit Python version 2.7. Every time I run a script (different Modules are called) and it fails, I need to close the program and open it again if I want to change the code. If I change the code without closing/opening IPython, my changes in the code are not “updated”.
I tired %reset, but it does not work. I tried ‘Ctrl’, ‘Ctrl+’. and ‘Crtl-‘ without success (nothing happen).
It is really annoying because I have to change the Conda environment everytime and restart IPython :).
Any tips? Would be great

Related

Spyder IDE with python 3.10 seems freezing when click run button, but it works fine if run a single line beforehand running the entire script

I have truble with last version of Spyder 5.4.0 with last version of Python 3.10.6.
Spyder version: 5.4.0 (conda)
Python version: 3.10.6 64-bit
Qt version: 5.15.2
PyQt5 version: 5.15.7
Operating System: Windows 10
Even if running a script like
print('Hello world')
when I click on the play green button, the IPython console seems freezing on this script, and it does not run for hours.
If I select this line of code and I run current selection or run the current cell it works fine. From this moment, it seems that spyder works fine, until at a certain point when I run it seems again freezing. I have to restart a new console and before running the script I have to run a single line or a single cell.
It seems that I have to 'activate' in someway the Python console in order to Spyder will run the script.
Does anyone have the same issue? How can I solve it?
I have tried to uninstall and reinstall both spyder and python many times, but it is useless.
After many trials, I noticed that there is something strange with IPython console. I noticed that when it hangs after running a code, if I delete all user variables, it worked fine.
Then I tryed to delete all variables before execution, and it work fine.
Therefore I discovered that a solution that worked for me is to go to preferences -> Run -> and untick the option 'Remove all variables before execution'
It is quite annoying because I have to do it manually every time before running, but in this way the spyder does not appear to hang anymore! I hope that the Spyder developers will solve it soon.
-
I automatically solved by typing at the beginning of any script these lines, inspired from the question Code to clear console and variables in Spyder :
try:
from IPython import get_ipython
get_ipython().magic('clear')
get_ipython().magic('reset -f')
import matplotlib.pyplot as plt
plt.close('all')
except:
pass
similar to Matlab in which you normally start your code with
clc
close all
clear all

Python 3.10 IDLE does not respond everytime I hit configure IDLE from options

I am a Windows 10 user, and had configured the Python 3.10 IDLE to dark mode and had added the Fira Code font to the IDLE a few days back (Through the Options menu). Then the Python IDLE was working fine; without issues.
However, each time after that when I try to go to 'Configure IDLE' from Options Menu, Python IDLE just freezes and then stops responding, until I manually close it. It then asks to run a Windows check and reports the error to Windows. I have tried uninstalling and reinstalling Python; however that did not work.
Image: Python has stopped responding (happens everytime I click on configure IDLE)
I am a Windows user and tried running python from cmd using the command: py -m idlelib to start IDLE from the command line to try and get an error report, however the same problem happens as mentioned above, and I do not get an error report when I close Python. I tried finding solutions in similar questions, however I did not understand what was going on. I also do not seem to figure out how 'running the Python IDLE' through the command line works, other than running it using the above command. Can someone please assist me on what to do next at this point, that would be of huge help :D
Try uninstalling the font. The Doesn't work part of the Editor compatibility list on https://github.com/tonsky/FiraCode includes IDLE. I suspect that the font is incompatible with tcl/tk. Your report is similar to
IDLE Settings window won't appear
See https://bugs.python.org/issue45103 for so far futile efforts to protect IDLE.
UPDATE: We were not able to reproduce the problem with FireCode. However, the BPO issue referenced above lead to a tcl/tk bug report that lead to a bugfix, at least for the Phaistos font, that is included in tcl/tk 8.6.12. This is included in the new Python 3.9.9 Windows installer and will be in the upcoming 3.10.1 installer. It might fix your issue with FiraCode.

Jupyter Notebook - Notebooks created on another computer are very slow to open and lag on typing

I've created a few notebooks on a previous Mac.
Since then, I've changed my Mac and reinstalled the new one from scratch, with the latest version of Anaconda (Python 2.7).
When I try to open these old notebooks, they are very long to open. Sometimes, it really takes 2-3 minutes in Safari. It sucks on loading MathJax/extensions/Safe.js.
Then, afterwards, it lags on typing : a few milliseconds between the keyboard action and the letters appearing in the cell.
I've been searching extensively on the web for this issue, but didn't find anything.
Uninstalling Anaconda and reinstalling again doesn't solve the issue.
Can it come from the fact that the Anaconda version I used to create the notebooks is probably not the same as the one I've installed on my new Mac ?
Thanks to all for your answer.
Perhaps a change in the browser. Google Chrome is advisable.
I have an old Mac and noticed something while using jupyter. Check your Activity monitor. If CPU is working like hell even tough you are not doing anything because of the process "VTDecoderXPCService" do this
Restart everything:
Right click quit on your browser in the dock
ctrl+c in your terminal where the notebook launched and restart again with "jupyter notebook"
I and I guess most Mac users don't shut down or really quit applications. It's just a guess but maybe you have the same problem. I don't know yet what is causing it but the macbook get's hot, a bit laggy and jupyter takes 2-3x as long to open a notebook.
Try Firefox. I think it is faster than Chrome for opening and viewing large notebook.

Stop execution of Python script (ctrl+C) in IPython using the Anaconda distribution

I am trying to stop execution of Python scripts in IPython in Windows. I have installed Python and IPython using Anaconda. However, whenever I press Ctrl+C, it breaks out of the current Python script as well as IPython. I saw a similar post here, which said to instead launch IPython with python C:\python27\scripts\ipython-script.py (or wherever that .py script is located), but for Anaconda users that script is in C:\Users\andre\Anaconda3\pkgs\ipython-5.1.0-py35_0\Scripts\ipython-script.py (which then changes with every version number if IPython that is installed). This ends up working but is certainly not convenient. I can make a quick shortcut/keybinding that runs that ipython-script.py script, but if and when I update IPython, I'm going to have to change the shortcut, and that seems rather inconvenient.
Any suggestions? I suppose I could add C:\Users\andre\Anaconda3\pkgs to my path, but that seems a little bit of overkill since there are a ton of packages in there.

IDLE 3.4.3 crashes when running module

I've recently started to use Python, and I don't know much about programming.
I've installed Python 3.4.3 in my Mac OS X Yosemite, and it worked fine for a few months, but now every time I want to run a module it stops responding.
so I use IDLE and when I open a new file to define a function I can write, then I click run and I save my file, and then when I click save IDLE doesn't restart as it use to and I can't write on it or do anything else. there is no crash report, no nothing, just all frozen. I close it and if then I re open and write on IDLE it works but as soon as I try to run a new file again it freezes.
How can I solve it?
to try stuff out i've been using repl.it online and it is useful for a learner like me but still I would like to be able to use IDLE on my mac.
THANK YOU FOR YOUR HELP!!!!
Try using Anaconda, which is another Python distribution, but more science-oriented. It has all the commonly required modules already in it (plus other for scientific purposes), so that you don't have to install them as and when required. And when you install Anaconda, it automatically installs Spyder, which is a much better IDE than IDLE.

Categories

Resources