spyder-ide / spyder

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

Spyder crashes when trying to save IPython console with graphics #6191

Closed master-nemo closed 6 years ago

master-nemo commented 6 years ago

Long time I was not reporting this, suspecting local compatibility troubles to cause it. But now all related libraryes (including PyQt4) updated and no warning messages in console shown. But trouble still here. Spyder crashes when trying to save IPython console when some graphics (from pyplot in my case) displayed in it. Similar print function works fine, saving single picture from console works too. But when selecting "Save as HTML/XML" it displays save-as dialog and after click "save" just crash all spyder without any log or traceback. So all I can provide as error information is screenshoots and windows error details from crash message.

What steps will reproduce the problem?

  1. execute something like

    import numpy as np
    import matplotlib.pyplot as plt
    plt.plot(np.sin(np.arange(314)/50.),'g--')
    plt.show()

    to display graphics in console

  2. right click on IPython console and select "Save as HTML/XML" (or just ctrl+s when IPython console in focus)

  3. select valid file name and click "save"

What is the expected output? What do you see instead? expected some resulted HTML but receive crash all spyder without log or trace. Windows error message is

Problem signature:
  Problem Event Name:   APPCRASH
  Application Name: pythonw.exe
  Application Version:  0.0.0.0
  Application Timestamp:    5488ac31
  Fault Module Name:    QtGui4.dll
  Fault Module Version: 4.8.7.0
  Fault Module Timestamp:   55655256
  Exception Code:   c0000005
  Exception Offset: 00055ac7
  OS Version:   6.1.7601.2.1.0.256.4
  Locale ID:    1049
  Additional Information 1: 0a9e
  Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
  Additional Information 3: 0a9e
  Additional Information 4: 0a9e372d3b4ad19135b953a78882e789  

Please provide any additional information below here is some screenshots of how it looks

Versions and main components

Dependencies

IPython >=4.0;<6.0: 5.5.0 (OK) cython >=0.21 : 0.25.2 (OK) jedi >=0.9.0 : 0.11.1 (OK) nbconvert >=4.0 : 5.3.1 (OK) numpy >=1.7 : 1.14.0 (OK) pandas >=0.13.1 : 0.22.0 (OK) pycodestyle >=2.3 : 2.3.1 (OK) pyflakes >=0.5.0 : 1.6.0 (OK) pygments >=2.0 : 2.2.0 (OK) pylint >=0.25 : 1.8.1 (OK) qtconsole >=4.2.0 : 4.3.1 (OK) rope >=0.9.4 : 0.10.7 (OK) sphinx >=0.6.6 : 1.6.6 (OK) sympy >=0.7.3 : 1.0 (OK)

ccordoba12 commented 6 years ago

This is (most probably) a problem with PyQt4, which stopped to be supported by Riverbank more than two years ago.

So please update to PyQt5 and reopen this issue if the crash is still present there.

CAM-Gerlach commented 6 years ago

Also, I could not reproduce this on my Spyder 3.2.5/PyQt5/Py3.6.3/Win 8.1 install.

master-nemo commented 6 years ago

thanks. PyQt5 unavailable for py2.7 but your supposal seems to explain this error so I will search for another way.

thanks again!

ccordoba12 commented 6 years ago

Yep, the other way is Anaconda. Please try it.

master-nemo commented 6 years ago

meanwhile in qtconsole (called by %qtconsole from main IPython console of Spyder) this function works fine (with PyQt4). UPD: this message- just for information. I not invite to do something with it. Seems it indeed my local trouble.

CAM-Gerlach commented 6 years ago

Have you installed a clean copy of the latest build of Anaconda (5.0.1), as @ccordoba12 suggested?

master-nemo commented 6 years ago

@ccordoba12, yes I tryed Anaconda (it work. no such error) (and Anaconda have PyQt5) but only in virtual PC - Anaconda can't support my current task.

So in practical mode I will use either Anaconda in virtual or save from %qtconsole (most likely). I continue to write here just because continue research on how to fix trouble locally (maybe someone have similar trouble and this may help).

CAM-Gerlach commented 6 years ago

Thanks for following up. As stated elsewhere, due to limited resources and the many tricky user-side problems with manual/pip installs and other distributions, we only are able to provide individual support for Anaconda installs, sorry, and regardless this issue appears outside our control. Hopefully your workarounds are helpful to others who have this problem and for some reason aren't able to just use Anaconda. I added a few appropriate tags for completeness and to help others find it, if need be.

master-nemo commented 6 years ago

thanks you. I understand how difficult it is to support for several environments so I do not ask for individual attention in my strange system configuration.

master-nemo commented 6 years ago

BTW. this is pure off-topic but strange thing: maybe I just not understand something. It appear when I tried to get verbose log.

when I start Spyder in regular way (spyder.exe or spyder.exe --show-console (I know it deprecated but)) option "View->Attached console window (debugging)" - not working. mark on this menu item appear but no console window is shown. I tryed strange command python.exe spyder.exe (please don't even ask how this strange idea come to my mind) - and this helps! - console window appear! (I suppose pythonw used for start in python.exe) (it is how it supposed to be?)

this work on my pip based configuration. when I tryed this on virtualPC with anaconda then "View->Attached console window (debugging)" not worked too and python.exe spyder.exe report error (as expected - .exe is not .py !)

C:\ProgramData\Anaconda2\Scripts>C:\ProgramData\Anaconda2\python.exe spyder.exe
  File "spyder.exe", line 1
SyntaxError: Non-ASCII character '\x90' in file spyder.exe on line 1, but no encoding declared; see ht
tp://python.org/dev/peps/pep-0263/ for details

so next: when I open console window in spyder for python3 then I see log for trying to save

QWindowsNativeFileDialogBase::onSelectionChange (QUrl("file:///C:/Users/Nemo/ipy
thon.html")) 1

But for python2.7 no messages appear in console window. (it is how it supposed to be or ?)

CAM-Gerlach commented 6 years ago

Interesting stuff; thanks for investigating further. As long as I actually started spyder from a console, (i.e. the Anaconda prompt), "Attached Console Window" worked just fine under PyQt5, Python 3.6 and Windows 8.1 Pro x64. If launched from the shortcut, it wouldn't do anything since there is no user-visible attached console window. Therefore, I'm unable to reproduce the problem. However, you'll welcome to take a look at it yourself and submit a PR; unfortunately we have limited resources as it is and are currently unfunded so I don't think we'll be able to look into it further at the moment. In any case, I'm not sure how you aren't able to just see the console you launched it from at the beginning; it shouldn't go anywhere (at least it never has on any of my machines).

You can start spyder just with spyder; no need for the .exe (at least under Anaconda), though it shouldn't make a difference. spyder.exe --show-console is deprecated because it is already set by default, so it doesn't actually do anything different than just spyder. spyder --debug is likely what you want as that will print debug messages to the console. That should help you isolate the error on your system.

master-nemo commented 6 years ago

spyder --debug

thanks! that is what I am looking for. but. it not working too. here is a screencast //1st command was a mistake- just forget to exit python console (called to show version)

I am so sorry :(( - so strange things is going on here.

CAM-Gerlach commented 6 years ago

Thanks a lot for recording that, it really does help. So, what's going on is that under your pip based setup, at least on your machine/configuration, when you run spyder you're starting it up in a new process independent of the launching console, as Administrator under a different set of user privileges. Therefore, it cannot show the attached console, as it is not attached to that console or nor a user-visible one (as you could see by the fact that it returned the prompt almost immediately and you could type in it). That is also why --debug doesn't likely work as it depends on it having an attached console to print the debug messages to (at least, that would make sense).

That's also why it does work when running python spyder as it is still attached to that console (as you can see), since python runs, under standard privileges and attached there, which then runs spyder. Not exactly sure why the debug flag doesn't work when launched the second way but it is likely due to it not being able to accept it when run in that state or not designed to do so, for whatever reason. So, basically everything is operating as it should, under the constraints of your OS and pip install method.

You can also try enabling debug mode by set ing the environment variable SPYDER_DEBUG=3 and then running from the same shell by either method. You can also try the steps listed in the Spyder Troubleshooting Guide, specifically the Basic First Aid and Emergency CPR sections, which resolve the great majority of Spyder installation issues.

As for your original issue, I wish we could do more to help, but again it is due to pip install method which is intended for experts able to solve problems like this on their own, as well as only occurring under the long out of date PyQt4, so with our limited resources I'm not sure how much we can do about it. However, you are welcome to give it a shot on your own, and if you can get it working feel free to submit a patch to fix it for everyone. Thanks, and best of luck!

master-nemo commented 6 years ago

...starting it up in a new process independent

good guess, but no. just trying it from cmd started with administrator privileges - same result.

and

SPYDER_DEBUG=3

is worked! thanks!

ok i will not bother you anymore... at least until find something that may lead to result.

thanks again for your help!

CAM-Gerlach commented 6 years ago

good guess, but no. just trying it from cmd started with administrator privileges - same result.

When I mentioned:

when you run spyder you're starting it up in a new process independent of the launching console, as Administrator under a different set of user privileges.

I meant that's what's actually happening in the first few attempts shown in your screencast and what's the proximate reason for the behavior you are seeing (and is a result of some peculiarity or another with your pip install), not what you should try. Sorry for the confusion.

is worked! thanks!

So you saw a bunch of debug messages printed to your console ("Starting MainWindow", etc)? And by which method, out of curiosity—spyder or python spyder?

Thanks for your replies, and hopefully you have good news to report soon.

master-nemo commented 6 years ago

And by which method, out of curiosity—spyder or python spyder?

work for python spyder.exe

simple spyder just start in different process and under pythonw as it was in video - so no connection to console and no new visible console

CAM-Gerlach commented 6 years ago

Right, just like I expected as well. Anyway, good luck!