spyder: Spyder doesn't launch: stuck on “Setting up main window”

Issue Report Checklist

  • Searched the issues page for similar reports
  • Read the relevant sections of the Spyder Troubleshooting Guide and followed its advice
  • Reproduced the issue after updating with conda update spyder (or pip, if not using Anaconda)
  • Could not reproduce inside jupyter qtconsole (if console-related)
  • Tried basic troubleshooting (if a bug/error)
    • Restarted Spyder
    • Reset preferences with spyder --reset
    • Reinstalled the latest version of Anaconda
    • Tried the other applicable steps from the Troubleshooting Guide
  • Completed the Problem Description, Steps to Reproduce and Version sections below

Problem Description

When I try to run Spyder on Ubuntu 16.10, it doesn’t launch and gets stuck on “Setting up main window” forever. No error messages are shown and it doesn’t crash.

When I try to run it from the source, the very same thing happens, and I get the message

Revision 03c7161, Branch: master

  1. Patched sys.path with /home/user/spyder/spyder
  2. PyQt5 is detected, selecting
  3. Imported Spyder 4.0.0.dev0 [Python 3.5.2 64bits, Qt 5.9.3, PyQt5 5.9.2 on Linux]
  4. Running Spyder Bootstrap completed in 00:00:00.5483

I tryied to debug the code and found that it doesn’t get past the line (which is in the file spyder/app/mainwindow.py)

self.console = Console(self, namespace, exitfunc=self.closing,
                            profile=self.profile,
                            multithreaded=self.multithreaded,
                            message=_("Spyder Internal Console\n\n"
                                    "This console is used to report application\n"
                                    "internal errors and to inspect Spyder\n"
                                    "internals with the following commands:\n"
                                    "  spy.app, spy.window, dir(spy)\n\n"
                                    "Please don't use it to run your code\n\n"))

Going deeper, it doesn’t go past the line sys.stdout = self.stdout_write at def redirect_stds(self) in spyder/interpreter.py.

What steps reproduce the problem?

  1. Try to run Spyder 3 or 4.

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

Spyder should launch. Instead, it gets stuck on “Setting up main window” forever. Spyder 2 runs just fine.

Paste Traceback/Error Below (if applicable)


  File "/home/user/spyder/spyder/spyder/app/mainwindow.py", line 3241, in main
    mainwindow = run_spyder(app, options, args)
  File "/home/user/spyder/spyder/spyder/app/mainwindow.py", line 3111, in run_spyder
    main.setup()
  File "/home/user/spyder/spyder/spyder/app/mainwindow.py", line 1175, in setup
    self.setup_layout(default=False)
  File "/home/user/spyder/spyder/spyder/app/mainwindow.py", line 1465, in setup_layout
    self.setup_default_layouts('default', settings)
  File "/home/user/spyder/spyder/spyder/app/mainwindow.py", line 1641, in setup_default_layouts
    widget.toggle_view(True)
  File "/home/user/spyder/spyder/spyder/plugins/ipythonconsole.py", line 760, in toggle_view
    self.create_new_client(give_focus=False)
  File "/home/user/spyder/spyder/spyder/plugins/ipythonconsole.py", line 1082, in create_new_client
    self.connect_client_to_kernel(client, is_cython=is_cython)
  File "/home/user/spyder/spyder/spyder/plugins/ipythonconsole.py", line 1120, in connect_client_to_kernel
    kc.start_channels(shell=True, iopub=True)
  File "/usr/local/lib/python3.5/dist-packages/qtconsole/kernel_mixins.py", line 43, in start_channels
    super(QtKernelClientMixin, self).start_channels(*args, **kw)
  File "/usr/local/lib/python3.5/dist-packages/jupyter_client/threaded.py", line 235, in start_channels
    self.ioloop_thread.start()
  File "/usr/local/lib/python3.5/dist-packages/jupyter_client/threaded.py", line 174, in start
    self._start_event.wait()
  File "/usr/lib/python3.5/threading.py", line 549, in wait
    signaled = self._cond.wait(timeout)
  File "/usr/lib/python3.5/threading.py", line 293, in wait
    waiter.acquire()
KeyboardInterrupt

## Versions
<!--- You can get this information from Help > About Spyder...
or (if Spyder won't launch) the "conda list" command
from the Anaconda Prompt/Terminal/command line. --->

* Spyder version: 3 and 4
* Python version: 3.5
* Qt version: 5.9.3
* PyQt version: 5.9.2
* Operating System name/version: Ubuntu 16.04

### Dependencies
<!--- Please go to the menu entry Help > Dependencies,
press the Copy to clipboard button and paste below --->

PASTE DEPENDENCIES HERE

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

I installed with PIP and I figured out the issue only happens with Python 3.8. I’ve tested on Python 3.7.5 and all works finely!

FYI i have the same and is related to jupyter/notebook#3595 and https://bugs.gentoo.org/648088 , still waiting for version dump dev-python/pyzmq >= v17

Exactly! This workaround did the trick for me:

  1. Open %YOUR_PYTHON_ENV_DIR%\Lib\site-packages\tornado\platform\asyncio.py where %YOUR_PYTHON_ENV_DIR% may be your Python3, Anaconda, Miniconda, env directory etc.
  2. Add above the line if typing.TYPE_CHECKING: (immediately below the imports):
if sys.platform == 'win32':
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

Now Spyder 4.1.2 runs fine with Python 3.8 😃

FYI i have the same and is related to https://github.com/jupyter/notebook/issues/3595 and https://bugs.gentoo.org/648088 , still waiting for version dump dev-python/pyzmq >= v17

@fbosio your fix worked like a charm, thanks.

@puneetmadaan Well, glad to ~hear~ read that! I must note though, that this fix in’t actually mine, but was proposed in this issue. And, according to @ccordoba12, this fix will not be needed in Spyder 4.1.3. Anyway, any contribution that I can make, even in an indirect way, makes me happier, so thank you very much for mentioning it! Regards.

¡Muchas gracias! 😃 Saludos

@violetina, please use Anaconda in the meantime.