spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.2k stars 1.59k forks source link

Need to press run twice with matplotlib in spyder #1831

Closed spyder-bot closed 7 years ago

spyder-bot commented 9 years ago

From markfran...@gmail.com on 2014-05-26T19:10:46Z

Spyder Version: 2.3.0beta2 Python Version: 3.3.5 Qt Version : 4.8.4, PyQt4 (API v2) 4.9.6 on Windows pyflakes >=0.6.0: None (OK) pep8 >=0.6 : None (NOK) IPython >=0.13 : 2.0.0 (OK) rope >=0.9.2 : 0.9.4 (OK) sphinx >=0.6.6 : 1.2.2 (OK) matplotlib >=1.0: 1.3.1 (OK) sympy >=0.7.0 : 0.7.5 (OK) pylint >=0.25 : 1.1.0 (OK)

What steps will reproduce the problem?

  1. Open a script with a matplotlib figure. For example one from the matplotlib site. http://matplotlib.org/mpl_examples/pylab_examples/figure_title.py 2. Press run or F5. It runs normally.
    1. Press run or F5 a second time and the script doesn't run
    2. Press run or F5 a third time then the script runs

What is the expected output? What do you see instead?

When you try to run a script with matplotlib you press run and it works normally the first time. Press run again and the script doesn't run. You have to hit run a second time in order for the script to run

Spyder is in "Execute in current python or ipython interpreter" mode

In the console it looks like this (i removed the file paths to make it shorter). F5 puts the runfile in. The second time you try to run it, when you click F5 or the green run arrow twice you runfile goes into the console twice before it runs.

">>> runfile('C:/.../figure_title.py', wdir=r'C:/...')

runfile('C:/.../figure_title.py', wdir=r'C:/...') runfile('C:/.../figure_title.py', wdir=r'C:/...') "

Please provide any additional information below

. I thought it was a problem with my own script, but the problem repeats even with code from the matplotlib website.

I only have this problem when I have a script with matplotlib. For example, when I run a simple script like below I can run it over and over no problem. I never have to press F5 twice.

x = int(input("enter an number: "))

if x < 0: x = 0 print('Negative') elif x > 0: print('Positive') elif x == 0: print('Zero')

Original issue: http://code.google.com/p/spyderlib/issues/detail?id=1831

spyder-bot commented 9 years ago

From dive...@gmail.com on 2015-02-04T13:51:24Z

Yes, I confirm that I need to press twice to run the above simple script in the standard console with Spyder 2.3.2 under Ubuntu.

All the previously reported issues related to this annoying bug, which make it impossible to debug in the console, are also present under Ubuntu with Python 3.

spyder-bot commented 9 years ago

From ccordoba12 on 2015-02-04T14:59:28Z

Bad, bad, bad. Unfortunately 2.3.3 is almost ready, so I'll see what I can about it for 2.3.4

Labels: MS-v2.3.4

spyder-bot commented 9 years ago

From dive...@gmail.com on 2015-02-05T01:52:25Z

I have the impression the Spyder developers have yet to make the transition to Python 3, otherwise they would realize how buggy Spyder looks under Python 3. Should one not try to make the console usable in Python 3 before making more Spyder official releases?

Note that I do understand that fixing that bug is difficult, otherwise it would not have eluded a solution for almost a year! But I feel this fix should have top priority and the person who fixes it should get a prize...

spyder-bot commented 9 years ago

From ccordoba12 on 2015-02-05T16:09:11Z

I introduced this bug on Linux while trying to fix issue #1930 (which was very serious too). It took me a couple of hours to understand what was happening with the interaction of both problems.

In any case, thanks for your insistence. At least I think I have a fix for Linux, which I'll include in 2.3.3.

spyder-bot commented 9 years ago

From dive...@gmail.com on 2015-02-06T00:32:27Z

That's interesting. If you can fix on Linux, don't you think something similar can fix on Windows too? The symptoms of the problem now look very similar on Linux and Windows...

spyder-bot commented 9 years ago

From ccordoba12 on 2015-02-09T06:38:30Z

I think I fixed issue #2022 as part of the efforts to fix this one. Please test the latest mercurial version and let me know if it's working for you or not.

ccordoba12 commented 9 years ago

@divenex, after many hours spent on this issue, I can say that it's very tricky and far from trivial to fix on Windows.

I'll consult some friends to try to solve it for 2.4. Sorry for the bad news.

stonebig commented 9 years ago

hi,

Going back to initial problem. with spyder launching in the current python IDE style console

When it doesn't run, i go to the console, and I type:

and then , the graphic then displays itself, it works (even if I have typed on the next blank prompt lines, stupidly).

(spyder 2.3.3, python 2.3.4, windows)

divenex commented 9 years ago

@ccordoba12 thanks for trying.

divenex commented 8 years ago

I must report this long standing bug is still there in 3.0.0b6.

ccordoba12 commented 8 years ago

Sorry, I really don't know how to solve this bug. Have you tried with Qt5? Does this bug appear with it too?

ccordoba12 commented 8 years ago

@divenex, I think I found a fix for this problem (after some experimentation :-) Will you be able to test it from a pull request?

divenex commented 7 years ago

@ccordoba12 sorry for my slow reply. I have now tested Spyder 3.0.0 with QT5 (qt: 5.6.0) and the problem is still there. The Python console is still completely unusable, and only the IPython console works. This is for Anaconda with Python 3.5 under Windows 10 64bit.

matthias2t commented 7 years ago

@ccordoba12 Sorry for the duplicated report. In case it could help, on my side, same configuration than divenex. I had to go back to version 3.0.0b6 (with exact same dependencies) to have it work. On the 3.0.0b7, the run command itself is not found, I got an error message. Thanks for your work anyway !

ccordoba12 commented 7 years ago

Yes, the problems with b7 were fixed in the final release.

brombeerberg commented 7 years ago

The bad behaviour described in the first comment of this issue seems to be still persistent. The two problems are:

  1. Scripts aren't running when 'Runf File' resp. F5 is pressed. One has to press it either twice or press enter in the console after the first F5
  2. When changing to another script the previous script is run after the procedure described in 1.

In my case all this started after updating from spyder 2 to 3. My configuration is:

athompson673 commented 7 years ago

Just want to bump this issue, and add something I haven't seen others mention..

With a fresh console, anything entered interactively returns immediately:

>>> 2+2
4

As others have stated running the current file with f5 requires clicking back to the console and hitting <return> again. After this all interactive entries also require an extra <return>:

>>> 2+2
>>> 
4

Running the file again continually increments the number of times I have to hit <return> to get a response back from the interpreter:

>>> 2+2
>>> 
>>>
>>>
>>>
>>>
4
ccordoba12 commented 7 years ago

I'm sorry but the Python console is going to be removed in Spyder 3.2, so we don't plan to fix this or any other bug related to it.

I'll create an issue explaining our reasons to do that, but one of the main ones is that the Python console is broken on Windows.

divenex commented 7 years ago

Let's not forget that the Python console is the only one that currently supports a command history during debugging. So I would not remove the Python console before implementing the command history in the IPython one.

I am still wondering how people can tolerate debugging in Spyder using the IPython console, without a command history!

FYI: The Linux version of Spyder, with a working Python console, can be used in Windows 10 with the Windows Subsystem for Linux

rpg32 commented 7 years ago

That is sad to hear that the Python console is going to be removed! I use that exclusively.

I have been having the same problem with the delayed execution after upgrading to Anaconda (1.5) and Spyder (3.1.3) with Python (3.6).

There is a simple workaround for those who wish to have similar functionality with the console while avoiding the delayed execution. Maybe it will help others.

Just go to the Run>Configure. Then in the 'Console' group switch from 'Execute in current Python or IPython console' to 'Execute in new dedicated Python console'.

I also checked 'Interact with the Python console after execution' and 'Show warning when killing running process'.

It is maybe not the best work around but at least it gets rid of the delayed execution.

ccordoba12 commented 7 years ago

@rpg32, unfortunately the Python console is holding us back on several fronts, and it's really unmaintained right now (I've done my best to fix its bugs throughout the years, but it's very hard to debug).

However, let me assure you that we will migrate all its features to the IPython console so that people don't miss a thing about it in 3.2.

divenex commented 7 years ago

@ccordoba12 it is great to hear you plan to migrate the Python Console features to the IPython one. In that case, it makes full sense to consolidate development onto a single console. I am looking forward to 3.2 then.

ccordoba12 commented 7 years ago

@divenex, that's the idea. I just added history browsing while debugging to the IPython console on PR #4202, so that would solve your major complaint about it.

Other missing functionality (e.g. running a file in a dedicated IPython console) will come in other PRs.

divenex commented 7 years ago

@ccordoba12 you are right, history browsing while debugging is indeed the only feature I have been missing in the IPython console. Excellent to see a PR about it.

ccordoba12 commented 7 years ago

Closing because the Python console is going to be removed in Spyder 3.2.

Please see issue #4524 for our reasons to do this.