spyder: Cannot start ipython kernel after fresh install of spyder within a conda environment in Windows 10

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

I am encountering an error inside ipython console in spyder after a fresh install in a new conda environment. This error is reproducible in python 3.5.x, 3.6.x, and 3.7.x and on two different PCs using Windows 10 and Windows 7. Also I have tried different anaconda channels — conda, anaconda, and conda-forge all leading to the same issue.

Starting jupyter qtconsole directly does not return the error bellow. Also running spyder from a pip installation does not reproduce the error.

A temporary solution I found is to downgrade ipykernel to version 4.8.2 which removes the error but adds the following warning message at the start of the console C:\Users\markovic\Miniconda3\envs\spyder\lib\site-packages\ipykernel\parentpoller.py:116: UserWarning: Parent poll failed. If the frontend dies, the kernel may be left running. Please let us know about your system (bitness, Python, etc.) at ipython-dev@scipy.org ipython-dev@scipy.org""")

What steps reproduce the problem?

  1. conda create -n spyder python=3
  2. conda activate spyder
  3. conda install spyder
  4. start spyder

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

In addition to the ipykernel error inside the console:

An error ocurred while starting the kernel
Traceback (most recent call last):
File "C:\Users\markovic\Miniconda3\envs\spyder\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\markovic\Miniconda3\envs\spyder\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\markovic\Miniconda3\envs\spyder\lib\site‑packages\spyder_kernels\console\__main__.py", line 11, in 
start.main()
File "C:\Users\markovic\Miniconda3\envs\spyder\lib\site‑packages\spyder_kernels\console\start.py", line 284, in main
kernel.initialize()
File "", line 2, in initialize
File "C:\Users\markovic\Miniconda3\envs\spyder\lib\site‑packages\traitlets\config\application.py", line 87, in catch_config_error
return method(app, *args, **kwargs)
File "C:\Users\markovic\Miniconda3\envs\spyder\lib\site‑packages\ipykernel\kernelapp.py", line 474, in initialize
self.init_io()
File "C:\Users\markovic\Miniconda3\envs\spyder\lib\site‑packages\ipykernel\kernelapp.py", line 326, in init_io
sys.stdout.flush()
AttributeError: 'NoneType' object has no attribute 'flush'
Traceback (most recent call last):
File "C:\Users\markovic\Miniconda3\envs\spyder\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\markovic\Miniconda3\envs\spyder\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\markovic\Miniconda3\envs\spyder\lib\site‑packages\spyder_kernels\console\__main__.py", line 11, in 
start.main()
File "C:\Users\markovic\Miniconda3\envs\spyder\lib\site‑packages\spyder_kernels\console\start.py", line 284, in main
kernel.initialize()
File "", line 2, in initialize
File "C:\Users\markovic\Miniconda3\envs\spyder\lib\site‑packages\traitlets\config\application.py", line 87, in catch_config_error
return method(app, *args, **kwargs)
File "C:\Users\markovic\Miniconda3\envs\spyder\lib\site‑packages\ipykernel\kernelapp.py", line 474, in initialize
self.init_io()
File "C:\Users\markovic\Miniconda3\envs\spyder\lib\site‑packages\ipykernel\kernelapp.py", line 326, in init_io
sys.stdout.flush()
AttributeError: 'NoneType' object has no attribute 'flush'
Traceback (most recent call last):
File "C:\Users\markovic\Miniconda3\envs\spyder\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\markovic\Miniconda3\envs\spyder\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\markovic\Miniconda3\envs\spyder\lib\site‑packages\spyder_kernels\console\__main__.py", line 11, in 
start.main()
File "C:\Users\markovic\Miniconda3\envs\spyder\lib\site‑packages\spyder_kernels\console\start.py", line 284, in main
kernel.initialize()
File "", line 2, in initialize
File "C:\Users\markovic\Miniconda3\envs\spyder\lib\site‑packages\traitlets\config\application.py", line 87, in catch_config_error
return method(app, *args, **kwargs)
File "C:\Users\markovic\Miniconda3\envs\spyder\lib\site‑packages\ipykernel\kernelapp.py", line 474, in initialize
self.init_io()
File "C:\Users\markovic\Miniconda3\envs\spyder\lib\site‑packages\ipykernel\kernelapp.py", line 326, in init_io
sys.stdout.flush()
AttributeError: 'NoneType' object has no attribute 'flush'
Traceback (most recent call last):
File "C:\Users\markovic\Miniconda3\envs\spyder\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\markovic\Miniconda3\envs\spyder\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\markovic\Miniconda3\envs\spyder\lib\site‑packages\spyder_kernels\console\__main__.py", line 11, in 
start.main()
File "C:\Users\markovic\Miniconda3\envs\spyder\lib\site‑packages\spyder_kernels\console\start.py", line 284, in main
kernel.initialize()
File "", line 2, in initialize
File "C:\Users\markovic\Miniconda3\envs\spyder\lib\site‑packages\traitlets\config\application.py", line 87, in catch_config_error
return method(app, *args, **kwargs)
File "C:\Users\markovic\Miniconda3\envs\spyder\lib\site‑packages\ipykernel\kernelapp.py", line 474, in initialize
self.init_io()
File "C:\Users\markovic\Miniconda3\envs\spyder\lib\site‑packages\ipykernel\kernelapp.py", line 326, in init_io
sys.stdout.flush()
AttributeError: 'NoneType' object has no attribute 'flush'

I also get the following warning inside the anaconda prompt js: Not allowed to load local resource: file:///C:/Users/usarename/Miniconda3/envs/spyder/lib/site-packages/spyder/utils/help/static/css/default.css This warning also disappears after a downgrade to ipykernel 4.8.2

Paste Traceback/Error Below (if applicable)

WARNING:traitlets:kernel restarted
WARNING:traitlets:kernel restarted
WARNING:traitlets:kernel restarted
WARNING:traitlets:kernel restarted
WARNING:traitlets:KernelRestarter: restart failed
WARNING:traitlets:kernel died: 18.00324773788452

Versions

  • Spyder version: 3.3.1
  • Python version: 3.7 (but also 3.6.x and 3.5.x)
  • Qt version: 5.9.6
  • PyQt version: 5.9.2
  • Operating System name/version: Win10 x64bit

Dependencies

IPython >=4.0     :  6.5.0 (OK)
cython >=0.21     :  None (NOK)
jedi >=0.9.0      :  0.12.1 (OK)
matplotlib >=2.0.0:  None (NOK)
nbconvert >=4.0   :  5.3.1 (OK)
numpy >=1.7       :  None (NOK)
pandas >=0.13.1   :  None (NOK)
pycodestyle >=2.3 :  2.4.0 (OK)
pyflakes >=0.6.0  :  2.0.0 (OK)
pygments >=2.0    :  2.2.0 (OK)
pylint >=0.25     :  2.1.1 (OK)
qtconsole >=4.2.0 :  4.4.1 (OK)
rope >=0.9.4      :  0.11.0 (OK)
sphinx >=0.6.6    :  1.7.8 (OK)
sympy >=0.7.3     :  None (NOK)

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 31 (17 by maintainers)

Commits related to this issue

Most upvoted comments

Please close Spyder, open an Anaconda Prompt, run there

conda install -n spyder ipykernel=4.8.2

and try again.

conda install -n spyder ipykernel=5.1

As you can see from the documentation, the -n flag performs the install into the named environment, and the error message therefore tells you that such an environment does not exist on your system (as you have not created it like the OP stated they did, with conda create -n spyder python=3.6).

Therefore, you should simply run conda install ipykernel=5.1 into whatever environment Spyder is installed in (base, by default) to accomplish the same, or else perform the steps as described by the OP to create a dedicated environment for Spyder, if you so choose.

The kernel 5.1.0 solves the problem (ipykernel-5.1.0 ):

conda install ipykernel Solving environment: done

Package Plan

environment location: …

added / updated specs: - ipykernel

The following packages will be downloaded:

package                    |            build
---------------------------|-----------------
ipykernel-5.1.0            |   py36h39e3cac_0         156 KB

The following packages will be UPDATED:

ipykernel: 4.9.0-py36_1 --> 5.1.0-py36h39e3cac_0

Proceed ([y]/n)? y

Downloading and Extracting Packages ipykernel-5.1.0 | 156 KB | #####################################################