Spyder IDE immediately crashed when hit the debug button - python

While optimizing the linear programming with linprog, I needed to update scipy from version 1.4.0 to 1.7.3 as it required to use highs methods.
With administrative help, we updated the conda using conda install -c conda-forge scipy=1.7.0 --yes. Luckily, it got updated. However, it is unfortunate that the spyder IDE started to crash when I hit the debug button with the dialog box (Figure_1_01262023.png), where details are:
File
"C:\ProgramData\Anaconda3\lib\site-packages\qtconsole\base_frontend_mixin.py",
line 138, in _dispatch
handler(msg) File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\ipythonconsole\widgets\debugging.py",
line 313, in _handle_input_request
if self._hidden: AttributeError: 'ShellWidget' object has no attribute '_hidden'
Figure 1
Note that while crashing, it does not close the interface, but all the run and debug buttons are not working. After then, I could not use the feature of debugging.
Then, I tried to update conda update -n base spyder and reset the spyder environment, but it didn't work, and I needed to restart the spyder IDE.

Related

Spyder 5.3.2 and 5.3.3 silently crash on startup

I'm using pip rather than conda to manage Spyder and all my python packages. I've found that in the last couple of spyder releases, trying to run spyder in the console results in my mouse cursor changing to the "working" cursor for a split second, then the command executes with no output and I'm on to the next line in the console. The Spyder window never appears. Version 5.3.1 works as expected, however. I've tried updating all my packages through pip but haven't had any success. Does anyone know what I can do to further troubleshoot this? I'm at a loss, since I'm not even getting an error message.

Spyder iPython console stuck at "Connecting to kernel..."

I am running Anaconda on a Windows 10 machine. When starting Spyder, the iPython console is stuck at "Connecting to kernel...". This appeared after my vacation - before the vacation I downgraded Spyder because the Python input() function was broken in the latest Spyder version. However, the following issue seems to appear no matter of which Spyder version I am using (currently 5.2.2).
On the other hand, if ipython is started from conda prompt it works fine.
I have tried the following suggestions that I found in multiple similar questions here on Stackoverflow, but to no avail:
Completely removing Anaconda and installing latest version.
Downgrading pyzmq to version 16.0.3 (this fails, Solving environment: failed)
Updating pyzmq to latest version
Updating ipykernel to latest version
Running spyder --reset
Any other suggestions?
This is really silly, but it seems like rebooting the computer fixed it.
When I was setting up custom Anaconda environment to use an older Python 3.6, I encountered the same issue.
The following worked for me.
Select Tools Menu > Select Preferences > Select Python Interpreter >
Select radio button 'Use the following Python interpreter:'
Use browsing icon and navigate to folder that points to your Python executable to set the textbox value. If you aren't sure where the python path is located. Then open a Command Prompt window and type 'where python'. Then choose your specific path from the output - copy and paste to the textbox mentioned above.
Click Apply > Click OK
Next
Select Tools menu > Select PYTHONPATH Manager
Remove any/all paths found
Click Close
The above directions resolved my issue. Beforehand I also tried the following functions listed below. It is possible that the following helped to partially resolve it too.
Open Command Prompt window
conda activate myenvironment
conda install spyder-kernels
conda update pyzmq
conda update ipykernel
Close Command Prompt window > Reload Anaconda.Navigator
Select myenvironment > Open Spyder

Python command prompt very slow to appear (Anaconda)

I've lately noticed an increasing lag when I fire up the CMD window to run python.
Immediately after entering "python", I see the python version info, but instead of the command prompt (>>>) I just get a blinking cursor (not showing in screenshot). After what's now become a couple of minutes, the command prompt finally appears, and I can run python code as usual.
When this happens, the CPU on my little work laptop is clearly under heavy load, the fan goes way up.
I have basically the same setup on my home PC (still with the older Anaconda and python 3.7) and never had any problems like this.
I was running python 3.7 in Anaconda on Windows 10. I just do simple scripts, copy and paste the code in a terminal window. In my original version, I had the base env + one clone, both had this problem.
I tried updating conda and anaconda but nothing changed. I thought it might be some dependency conflicts (I had recently pip-installed a couple of heavy-ish packages into my clone env: pytessearct and openpyxl), so I finally uninstalled Anaconda and reinstalled the latest version (Anaconda3-2020.07-Windows-x86_64 with python 3.8) with the standard packages, and I still have the same problem.
One related clue: Anaconda Navigator was also hecka slow to load. I tried disabling SSL verification per this thread (Anaconda navigator VERY slow) but it had no effect on the time delay for the python command prompt. But with the fresh install, Navigator now loads normally.
In my new install, I did the same setup, base + clone, both with the standard Anaconda package set, no add-ons, I still have the same problem in both envs.

Why do I get a list of errors when trying to load matplotlib in PyCharm with the Anaconda environment?

I have installed PyCharm with Anaconda. I installed numpy fine using the PyCharm settings by adding the package via the Project Interpreter tab. However I am now trying to install matplotlib and I get a list of errors.
Just by including the line
import matplotlib.pyplot as plt
I get the errors:
AttributeError: module 'matplotlib.pyplot' has no attribute 'switch_backend'
Matplotlib support failed
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm 2018.2.4\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 23, in do_import
succeeded = activate_func()
File "C:\Program Files\JetBrains\PyCharm 2018.2.4\helpers\pydev\_pydev_bundle\pydev_console_utils.py", line 199, in <lambda>
"matplotlib": lambda: activate_matplotlib(self.enableGui),
File "C:\Program Files\JetBrains\PyCharm 2018.2.4\helpers\pydev\pydev_ipython\matplotlibtools.py", line 96, in activate_matplotlib
gui, backend = find_gui_and_backend()
File "C:\Program Files\JetBrains\PyCharm 2018.2.4\helpers\pydev\pydev_ipython\matplotlibtools.py", line 47, in find_gui_and_backend
backend = matplotlib.rcParams['backend']
File "C:\Users\calcl\Anaconda3\envs\PXP\lib\site-packages\matplotlib\__init__.py", line 892, in __getitem__
plt.switch_backend(rcsetup._auto_backend_sentinel)
What could be causing this problem and how would I resolve it?
I am using Python 3.6 with 3.0.0 Matplotlib and PyCharm 2018.2.4
Like #BigFish wrote, this is a bug in PyCharm side, you can see the bug report here.
It's fixed in PyCharm 2018.3, so the easiest solution is to upgrade PyCharm.
Alternative workarounds are downgrading matplotlib, or unchecking "run with python console" in the run configuration:
This will allow you to run/debug, but you'll still get those errors if you use the interactive console.
As a side note, PyCharm has a history of lagging behind matplotlib API changes, so this should be your first guess next time...
I encountered the same error using Python 3.6 with 3.0.0 Matplotlib and PyCharm 2018.2.4. The error is evidently on the Pycharm side, as indicated by the traceback and by the fact that importing matplotlib via the anaconda prompt or spyder IDE does not produce this error.
The 'switch backend' utility seems to be a new feature according to the release notes of matplotlib https://github.com/matplotlib/matplotlib/releases. As pointed out in #Psychotechnopath's answer, it might be some issue with the path, so that Pycharm can't find the switch backend module when it is called by the Pycharm scripts in your Traceback.
However I don't think manually adding anything to the path is a desirable and robust solution. Instead, I downgraded matplotlib to version 2.2.3 using the conda installer in the Anaconda Prompt:
conda install matplotlib=2.2.3
After this downgrade I was able to import matplotlib in Pycharm again without any issues.
Probably you did not "add to path" when installing Anaconda, or you are not running PyCharm from an activated conda environment. Running Pycharm without an activated environment is unsupported, and results in issues when trying to install packages. Two solutions you could try:
Reinstall Anaconda and tick the option "Add to path". Make sure you know what this means, by for instance looking at this post: Why (or why not) Add Anaconda to path?
because if you have multiple python installations on path this could cause issues (That's why Anaconda warns you to do this when installing). Summarized, adding Anaconda to path makes it easier for programs like PyCharm to find where everything is installed, thus decreasing the chance for import errors.
Boot Anaconda prompt, and activate the environment you wish to use, by activate Environmentname. If you never use seperate environments, but just the base/root environment you don't need to activate anything, since booting the Anaconda prompt automatically activates the base/root environment. After the environment of choice is activated, boot PyCharm from this prompt.
Let me know if that solved your issues =)

Anaconda after update: Command propmpt responding very slowly and IPython not loading

I ran the conda update --all command, but unfortunately something went wrong with the update process and windows crashed. Now if I try to redo the update the terminal is responding very slowly, to the point where installing the update is impossible. Even worse I ran conda update ipython, which also executed very slowly and now the ipython console no longer works reporting: ImportError: No module named 'IPython.kernel.zmq.kernelapp'.
I tried to update anaconda as I recived the error: line magic function %pyomo not found, when executing one of the basic examples using pyomo.
What should be done to restore anaconda? I am using the Spyder IDE.

Categories