Repository: spyder-ide/spyder

Issue:
No QcoreApplication Found - Spyder 5 installation problem 
During installation of spyder 5 on Ubuntu 20.04. The following error appears. 


"No QCoreApplication instance found. Application patches not applied. You have to call load_stylesheet function after instantiation of QApplication to take effect. "

The IDE doesn't launch. 

Is there a way to fix this ?








Discussion:
I have a similar problem.

i have not found a solution yet, but when running it with python to get the error logs, it seems like that during the init spyder is not able to find all icons. The first one was mdi.check-bold, which i testwise replaced for now, but now i am having the same problem with mdi.content-save-edit

@agos316 Did you also use pip for installing spyder?

I installed using conda. I really like this IDE so I hope the problem is fixed soon.

I checked all the dependencies and everything seemed to be in line. 
Same error for Spyder 5 installed using miniconda on MacOS Catalina 10.15.7. 

A fix or workaround would be greatly appreciated! I've reverted to 4.2.5 for the moment.
okay i moved on and also replaced couple of the other icons that were not found.
(when running the program from with in python ==> i got exception messages like this:

`Exception: Invalid icon name "source-repository" in font "mdi"`

I than replaced them by modifing the corresponding lines in the file: icon_manager.py which you can find in:
"your python install folder"/Lib/site-packages/spyder/utils

In this file you will find a class called IconManager which has an attribute called _qtaargs. This attribute seems to be a big dictonary mapping some operation to the corresponding icons. There one can find the "invalid icon names" in the form font.icon_name. I replaced them with some icon that seemed familiar with the required one. So e.g I replaced the above one with  mdi.source-commit.

I will attach my modified version of the file. But this should definitely be only a temporary fix and i am not 100% confident that this might also help you (needed to change file type to txt ;))
[icon_manager.py.txt](https://github.com/spyder-ide/spyder/files/6272633/icon_manager.py.txt). 

 Now it at least starts. Even though it still has a bug with the icons (see the attached screenshot).
![Spyder_bug_icons](https://user-images.githubusercontent.com/4347891/113891315-406a6c80-97c5-11eb-83cc-2556f339c473.png)

It also gives me now in spyder on the gui the error message, that i have the wrong version of spyder-kernels, which i so far tried to solve by updating it with pip. Which told me that spyder kernels would be allready on the newest version. 

Wow @ITWARRIORS-Kilian  thats pretty cool that you got it to run,I might try this, I hope a long term solution is available soon. 

Hi @agos316 thanks for the feedback! Regarding the message `No QCoreApplication found...` I think is just a warning. However seems like an error regarding the mapping of the icons is preventing Spyder to launch (if you are having a similar issue as @ITWARRIORS-Kilian).

@agos316 or @emmaworthington could you check if running Spyder with the `--debug-info verbose` flag gives us more information to check a possible traceback before Spyder crashes? (Like for example the errors mentioned by @ITWARRIORS-Kilian regarding being unable to load some icons). Also, could you provide more information about your setup (dependencies, OS, an in general the information requested in the issue template)? Any new info is greatly appreciated!

@ITWARRIORS-Kilian about the pop-up dialog saying that the `spyder-kernels` version is incorrect, it was a bug but we already solve it at #15100 . Similarly with the icons in the menus and actions, we also did some fixes for that. Those fixes will be soon available (they will be released inside [Spyder 5.0.1](https://github.com/spyder-ide/spyder/milestone/102))

@agos316 @emmaworthington in terms of a workaround, if the launching problem is related with the icons, you could try to use the `Spyder 2` icon-set. For that you need to locate the file where Spyder saves its preferences (usually at \<user directory or home directory\>/.spyder-py3/config/spyder.ini) and inside the file change the `icon_theme` value from `spyder 3` to `spyder 2`

Let us know if something of the above helps! (or at least helps clarifying the status of things :) )



@dalthviz I ran the debug, and it led to the same call back. 

File "/home/qtconsole/util.py", line 64, in __new__
    QClass.__init__(inst)
TypeError: __init__() missing 1 required positional argument: 'context'

Here is what it says after before closing out 
 
Thank you for the response @agos316 in that case the issue is related with a new release of `jupyter_client` could you downgrade to `jupyter_client=6.1.12` and test again, please?
@dalthviz That did it ! Thank you for your help

Thanks to all that replied as well

@ITWARRIORS-Kilian could you open a new issue for the errors you were experiencing with the icons, please? Seems like the issue here was different. Thanks!

@emmaworthington let us know if downgrading `jupyter_client` helps in your case too

I can confirm that "No QCoreApplication instance found. Application patches not applied. You have to call load_stylesheet function after instantiation of QApplication to take effect. " is present for bootstrap on macOS and the macOS application but does not inhibit launching.

Also, regarding `jupyter_client=6.1.13`, see #15180.
I also confirm the same error for Spyder 5 installed using conda on Win10 20H2 but the application launches and works.  The jupyter_client fix did not eliminate the error message.

I also get the spyder-kernels 2.0.1 version not being present but checking via anaconda the proper version is there for the environment. 

The only issue for me seems to be the icons overlapping with menu and tab items, see the tab overlap with the navigation arrows in the picture below
![image](https://user-images.githubusercontent.com/28820411/113981480-65f08800-9850-11eb-9edd-68b80f564c60.png)

@yiorgosn, that will also be fixed in 5.0.1, to be released shortly. 
Hi,
I get the warning "No QCoreApplication instance found. Application patches not applied. You have to call load_stylesheet function after instantiation of QApplication to take effect." but the application launches okay. My jupyter-client version was already 6.1.12.

I also get the spyder-kernels missing dependencies popup, but I have v2.0.1 installed by conda.

Thanks



Hey @emmaworthington, you said

> also get the spyder-kernels missing dependencies popup, but I have v2.0.1 installed by conda.

That's a duplicate of issue #15091 and it'll be fixed in our next version (5.0.1), to be released shortly.
Carlos, Thanks for your and your team's great work and being so responsive.  Spyder is awesome and I love the job you all do!  
Hello-

Thank you for your work on this program.

I don't know if this is related, and if not I apologize. It does however at least begin with the same error message. I suspect that this may be a similar manifestation of a different problem. Please let me know if you would like me to start a new thread.

I have spyder installed via the anaconda platform on Windows 10. After updating to version 5, spyder launched precisely once, and now refuses to again. Launching from the Start menu, the splash screen closes saying "Initializing...". When I launch through the anaconda launcher I get the tracebacks below. As mentioned earlier in this thread, I forced jupyter-client==6.1.12, with the same results. 

I tried removing and reinstalling spyder with the same result. When the problem persisted through a reinstall, I figured that it must be related to a user setting, so, I renamed .spyder-py3 to .spyder-py3.bak. _This seems to have solved the problem._ Spyder now launches without error.

(As an aside, when I did have it open initially, I noted that the editor was extremely laggy. I've noticed this behavior on High-DPI screens with the version 4 releases, and this was actually the reason for my upgrade. After clearing the hidden folder, this issue also appears to have disappeared. I haven't had the opportunity to try it on other screen configurations, so, it's possible that I'll have to reconfigure something and it will return.)

Please let me know if I may be of any additional assistance with this issue.
--Chad Parker

No QCoreApplication instance found. Application patches not applied. You have to call load_stylesheet function after instantiation of QApplication to take effect. 
Pruned plugin: outline_explorer
Traceback (most recent call last):
File "C:\Users\parkecw1\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 2146, in create_window
main.setup()
File "C:\Users\parkecw1\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 847, in setup
plugin_instance = plugin_class(self)
File "C:\Users\parkecw1\Anaconda3\lib\site-packages\spyder\plugins\editor\plugin.py", line 196, in __init__
self._setup()
File "C:\Users\parkecw1\Anaconda3\lib\site-packages\spyder\plugins\base.py", line 415, in _setup
self._plugin_actions = self.get_plugin_actions() + [MENU_SEPARATOR,
File "C:\Users\parkecw1\Anaconda3\lib\site-packages\spyder\plugins\editor\plugin.py", line 492, in get_plugin_actions
self.register_shortcut(self.new_action, context="Editor",
File "C:\Users\parkecw1\Anaconda3\lib\site-packages\spyder\api\plugins.py", line 354, in register_shortcut
super(BasePluginWidget, self)._register_shortcut(
File "C:\Users\parkecw1\Anaconda3\lib\site-packages\spyder\plugins\base.py", line 434, in _register_shortcut
self.main.register_shortcut(
File "C:\Users\parkecw1\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 1403, in register_shortcut
self.shortcuts.register_shortcut(
File "C:\Users\parkecw1\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 1164, in __getattr__
return super().__getattr__(attr)
AttributeError: 'MainWindow' object has no attribute 'shortcuts'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\parkecw1\Anaconda3\Scripts\spyder-script.py", line 10, in 
sys.exit(main())
File "C:\Users\parkecw1\Anaconda3\lib\site-packages\spyder\app\start.py", line 214, in main
mainwindow.main(options, args)
File "C:\Users\parkecw1\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 2293, in main
mainwindow = create_window(app, splash, options, args)
File "C:\Users\parkecw1\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 2148, in create_window
if main.console is not None:
File "C:\Users\parkecw1\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 1159, in __getattr__
return self.get_plugin(self._INTERNAL_PLUGINS_MAPPING[attr])
File "C:\Users\parkecw1\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 168, in get_plugin
raise SpyderAPIError('Plugin "{}" not found!'.format(plugin_name))
spyder.api.exceptions.SpyderAPIError: Plugin "internal_console" not found!

@technobauble, please open a new issue about your problem. It's completely unrelated to this.
I get this warning on Ubuntu 18.04 as well, although Spyder still launches
Hi @jamesmhbarry yep is just a warning but since it could be kind of misleading (you could think something bad is happening) we are thinking to remove/hide it in a future release

Resolving patch:
diff --git a/spyder/app/start.py b/spyder/app/start.py
--- a/spyder/app/start.py
+++ b/spyder/app/start.py
@@ -9,6 +9,7 @@
 
 # Standard library imports
 import ctypes
+import logging
 import os
 import os.path as osp
 import random
@@ -16,7 +17,19 @@
 import sys
 import time
 
-# To prevent a race condition with ZMQ
+# Prevent showing internal logging errors
+# Fixes spyder-ide/spyder#15768
+logging.raiseExceptions = False
+
+# Prevent that our dependencies display warnings when not in debug mode.
+# Some of them are reported in the console and others through our
+# report error dialog.
+# Note: The log level when debugging is set on the main window.
+# Fixes spyder-ide/spyder#15163
+root_logger = logging.getLogger()
+root_logger.setLevel(logging.ERROR)
+
+# Prevent a race condition with ZMQ
 # See spyder-ide/spyder#5324.
 import zmq
 


Test patch: