【问题标题】: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 scriptSpyder 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
【发布时间】:2022-12-02 01:39:35
【问题描述】:

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.

【问题讨论】:

标签: python anaconda ide spyder miniconda


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2022-12-19
    • 2022-12-27
    • 2015-04-06
    • 1970-01-01
    • 2022-12-02
    • 2019-09-21
    • 1970-01-01
    • 2022-12-02
    • 1970-01-01
    相关资源
    最近更新 更多