question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Spyder is interfering with Dask

See original GitHub issue

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

Hello, Dask is a library for parallel computing in python that follows the pandas/numpy API (https://dask.org). I always used Dask and Spyder together, however, after the recent update to Spyder 4, they do not seem to work together anymore. What is happening is that after opening a Client and running for the first time the script in Spyder, all subsequent times the script does not start, instead, an error is returned and the console just hangs. The only solution I have found for now is to restart the kernel every time I want to run the script. That is why I came back to Spyder 3.3.6 which does not show this behavior. Attached below a MWE and my working configuration as well as a yml anaconda env file to reproduce the problem.

What steps reproduce the problem?

  1. Open Spyder and run the following script:

from dask.distributed import Client

if __name__=='__main__':
    print('hello')
    client = Client()
    client.close()
  1. Run the script again

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

The expected output should be the following:

In [1]:
hello

In [2]:
hello

In [3]:

Just a print of the hello string and a new cell in the console.

Paste Traceback/Error Below (if applicable)


In [1]:
hello

In [2]:
hello
Task exception was never retrieved
future: <Task finished coro=<_wrap_awaitable() done, defined at /Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/asyncio/tasks.py:530> exception=AttributeError("module '__main__' has no attribute '__spec__'",)>
Traceback (most recent call last):
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/asyncio/tasks.py", line 537, in _wrap_awaitable
    return (yield from awaitable.__await__())
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/site-packages/distributed/nanny.py", line 251, in start
    response = await self.instantiate()
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/site-packages/distributed/nanny.py", line 334, in instantiate
    result = await self.process.start()
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/site-packages/distributed/nanny.py", line 522, in start
    await self.process.start()
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/site-packages/distributed/process.py", line 34, in _call_and_set_future
    res = func(*args, **kwargs)
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/site-packages/distributed/process.py", line 202, in _start
    process.start()
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/multiprocessing/process.py", line 105, in start
    self._popen = self._Popen(self)
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/multiprocessing/context.py", line 284, in _Popen
    return Popen(process_obj)
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/multiprocessing/popen_fork.py", line 19, in __init__
    self._launch(process_obj)
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/multiprocessing/popen_spawn_posix.py", line 42, in _launch
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/multiprocessing/spawn.py", line 172, in get_preparation_data
    main_mod_name = getattr(main_module.__spec__, "name", None)
AttributeError: module '__main__' has no attribute '__spec__'
Task exception was never retrieved
future: <Task finished coro=<_wrap_awaitable() done, defined at /Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/asyncio/tasks.py:530> exception=AttributeError("module '__main__' has no attribute '__spec__'",)>
Traceback (most recent call last):
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/asyncio/tasks.py", line 537, in _wrap_awaitable
    return (yield from awaitable.__await__())
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/site-packages/distributed/nanny.py", line 251, in start
    response = await self.instantiate()
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/site-packages/distributed/nanny.py", line 334, in instantiate
    result = await self.process.start()
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/site-packages/distributed/nanny.py", line 522, in start
    await self.process.start()
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/site-packages/distributed/process.py", line 34, in _call_and_set_future
    res = func(*args, **kwargs)
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/site-packages/distributed/process.py", line 202, in _start
    process.start()
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/multiprocessing/process.py", line 105, in start
    self._popen = self._Popen(self)
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/multiprocessing/context.py", line 284, in _Popen
    return Popen(process_obj)
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/multiprocessing/popen_fork.py", line 19, in __init__
    self._launch(process_obj)
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/multiprocessing/popen_spawn_posix.py", line 42, in _launch
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/multiprocessing/spawn.py", line 172, in get_preparation_data
    main_mod_name = getattr(main_module.__spec__, "name", None)
AttributeError: module '__main__' has no attribute '__spec__'
Task exception was never retrieved
future: <Task finished coro=<_wrap_awaitable() done, defined at /Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/asyncio/tasks.py:530> exception=AttributeError("module '__main__' has no attribute '__spec__'",)>
Traceback (most recent call last):
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/asyncio/tasks.py", line 537, in _wrap_awaitable
    return (yield from awaitable.__await__())
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/site-packages/distributed/nanny.py", line 251, in start
    response = await self.instantiate()
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/site-packages/distributed/nanny.py", line 334, in instantiate
    result = await self.process.start()
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/site-packages/distributed/nanny.py", line 522, in start
    await self.process.start()
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/site-packages/distributed/process.py", line 34, in _call_and_set_future
    res = func(*args, **kwargs)
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/site-packages/distributed/process.py", line 202, in _start
    process.start()
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/multiprocessing/process.py", line 105, in start
    self._popen = self._Popen(self)
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/multiprocessing/context.py", line 284, in _Popen
    return Popen(process_obj)
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/multiprocessing/popen_fork.py", line 19, in __init__
    self._launch(process_obj)
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/multiprocessing/popen_spawn_posix.py", line 42, in _launch
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/multiprocessing/spawn.py", line 172, in get_preparation_data
    main_mod_name = getattr(main_module.__spec__, "name", None)
AttributeError: module '__main__' has no attribute '__spec__'
Task exception was never retrieved
future: <Task finished coro=<_wrap_awaitable() done, defined at /Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/asyncio/tasks.py:530> exception=AttributeError("module '__main__' has no attribute '__spec__'",)>
Traceback (most recent call last):
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/asyncio/tasks.py", line 537, in _wrap_awaitable
    return (yield from awaitable.__await__())
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/site-packages/distributed/nanny.py", line 251, in start
    response = await self.instantiate()
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/site-packages/distributed/nanny.py", line 334, in instantiate
    result = await self.process.start()
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/site-packages/distributed/nanny.py", line 522, in start
    await self.process.start()
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/site-packages/distributed/process.py", line 34, in _call_and_set_future
    res = func(*args, **kwargs)
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/site-packages/distributed/process.py", line 202, in _start
    process.start()
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/multiprocessing/process.py", line 105, in start
    self._popen = self._Popen(self)
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/multiprocessing/context.py", line 284, in _Popen
    return Popen(process_obj)
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/multiprocessing/popen_fork.py", line 19, in __init__
    self._launch(process_obj)
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/multiprocessing/popen_spawn_posix.py", line 42, in _launch
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "/Users/username/opt/anaconda3/envs/dask-spyder/lib/python3.6/multiprocessing/spawn.py", line 172, in get_preparation_data
    main_mod_name = getattr(main_module.__spec__, "name", None)
AttributeError: module '__main__' has no attribute '__spec__'

Versions

  • Spyder version: 4.1.2 (this behavior is reproducible with all the released v4 of Spyder)
  • Python version: 3.6.10
  • Qt version: 5.9.6
  • PyQt version: 5.9.2
  • Operating System name/version: macOS Catalina 10.15.4

Dependencies

name: dask-spyder
channels:
  - defaults
dependencies:
  - alabaster=0.7.12=py36_0
  - applaunchservices=0.2.1=py_0
  - appnope=0.1.0=py36hf537a9a_0
  - argh=0.26.2=py36_0
  - asn1crypto=1.3.0=py36_0
  - astroid=2.3.3=py36_0
  - atomicwrites=1.3.0=py36_1
  - attrs=19.3.0=py_0
  - autopep8=1.4.4=py_0
  - babel=2.8.0=py_0
  - backcall=0.1.0=py36_0
  - blas=1.0=mkl
  - bleach=3.1.4=py_0
  - bokeh=2.0.1=py36_0
  - ca-certificates=2020.1.1=0
  - certifi=2020.4.5.1=py36_0
  - cffi=1.14.0=py36hb5b8e2f_0
  - chardet=3.0.4=py36_1003
  - click=7.1.1=py_0
  - cloudpickle=1.3.0=py_0
  - cryptography=2.8=py36ha12b0ac_0
  - cytoolz=0.10.1=py36h1de35cc_0
  - dask=2.14.0=py_0
  - dask-core=2.14.0=py_0
  - dbus=1.13.12=h90a0687_0
  - decorator=4.4.2=py_0
  - defusedxml=0.6.0=py_0
  - diff-match-patch=20181111=py_0
  - distributed=2.14.0=py36_0
  - docutils=0.16=py36_0
  - entrypoints=0.3=py36_0
  - expat=2.2.6=h0a44026_0
  - flake8=3.7.9=py36_0
  - freetype=2.9.1=hb4e5f40_0
  - fsspec=0.7.1=py_0
  - future=0.18.2=py36_0
  - gettext=0.19.8.1=h15daf44_3
  - glib=2.63.1=hd977a24_0
  - heapdict=1.0.1=py_0
  - icu=58.2=h4b95b61_1
  - idna=2.9=py_1
  - imagesize=1.2.0=py_0
  - importlib_metadata=1.5.0=py36_0
  - intel-openmp=2019.4=233
  - intervaltree=3.0.2=py_0
  - ipykernel=5.1.4=py36h39e3cac_0
  - ipython=7.13.0=py36h5ca1d4c_0
  - ipython_genutils=0.2.0=py36_0
  - isort=4.3.21=py36_0
  - jedi=0.15.2=py36_0
  - jinja2=2.11.1=py_0
  - jpeg=9b=he5867d9_2
  - jsonschema=3.2.0=py36_0
  - jupyter_client=6.1.2=py_0
  - jupyter_core=4.6.3=py36_0
  - keyring=21.1.1=py36_2
  - lazy-object-proxy=1.4.3=py36h1de35cc_0
  - libcxx=4.0.1=hcfea43d_1
  - libcxxabi=4.0.1=hcfea43d_1
  - libedit=3.1.20181209=hb402a30_0
  - libffi=3.2.1=h0a44026_6
  - libgfortran=3.0.1=h93005f0_2
  - libiconv=1.15=hdd342a3_7
  - libpng=1.6.37=ha441bb4_0
  - libsodium=1.0.16=h3efe00b_0
  - libspatialindex=1.9.3=h0a44026_0
  - libtiff=4.1.0=hcb84e12_0
  - locket=0.2.0=py36hca03003_1
  - markupsafe=1.1.1=py36h1de35cc_0
  - mccabe=0.6.1=py36_1
  - mistune=0.8.4=py36h1de35cc_0
  - mkl=2019.4=233
  - mkl-service=2.3.0=py36hfbe908c_0
  - mkl_fft=1.0.15=py36h5e564d8_0
  - mkl_random=1.1.0=py36ha771720_0
  - msgpack-python=1.0.0=py36h04f5b5a_1
  - nbconvert=5.6.1=py36_0
  - nbformat=5.0.4=py_0
  - ncurses=6.2=h0a44026_0
  - numpy=1.18.1=py36h7241aed_0
  - numpy-base=1.18.1=py36h6575580_1
  - numpydoc=0.9.2=py_0
  - olefile=0.46=py36_0
  - openssl=1.1.1g=h1de35cc_0
  - packaging=20.3=py_0
  - pandas=1.0.3=py36h6c726b0_0
  - pandoc=2.2.3.2=0
  - pandocfilters=1.4.2=py36_1
  - parso=0.5.2=py_0
  - partd=1.1.0=py_0
  - pathtools=0.1.2=py_1
  - pcre=8.43=h0a44026_0
  - pexpect=4.8.0=py36_0
  - pickleshare=0.7.5=py36_0
  - pillow=7.0.0=py36h4655f20_0
  - pip=20.0.2=py36_1
  - pluggy=0.13.1=py36_0
  - prompt-toolkit=3.0.4=py_0
  - prompt_toolkit=3.0.4=0
  - psutil=5.7.0=py36h1de35cc_0
  - ptyprocess=0.6.0=py36_0
  - pycodestyle=2.5.0=py36_0
  - pycparser=2.20=py_0
  - pydocstyle=4.0.1=py_0
  - pyflakes=2.1.1=py36_0
  - pygments=2.6.1=py_0
  - pylint=2.4.4=py36_0
  - pyopenssl=19.1.0=py36_0
  - pyparsing=2.4.6=py_0
  - pyqt=5.9.2=py36h655552a_2
  - pyrsistent=0.16.0=py36h1de35cc_0
  - pysocks=1.7.1=py36_0
  - python=3.6.10=hc70fcce_1
  - python-dateutil=2.8.1=py_0
  - python-jsonrpc-server=0.3.4=py_0
  - python-language-server=0.31.10=py36_0
  - python.app=2=py36_10
  - pytz=2019.3=py_0
  - pyyaml=5.3.1=py36h1de35cc_0
  - pyzmq=18.1.1=py36h0a44026_0
  - qdarkstyle=2.8.1=py_0
  - qt=5.9.7=h468cd18_1
  - qtawesome=0.7.0=py_0
  - qtconsole=4.7.3=py_0
  - qtpy=1.9.0=py_0
  - readline=8.0=h1de35cc_0
  - requests=2.23.0=py36_0
  - rope=0.16.0=py_0
  - rtree=0.9.3=py36_0
  - setuptools=46.1.3=py36_0
  - sip=4.19.8=py36h0a44026_0
  - six=1.14.0=py36_0
  - snowballstemmer=2.0.0=py_0
  - sortedcontainers=2.1.0=py36_0
  - sphinx=2.4.4=py_0
  - sphinxcontrib-applehelp=1.0.2=py_0
  - sphinxcontrib-devhelp=1.0.2=py_0
  - sphinxcontrib-htmlhelp=1.0.3=py_0
  - sphinxcontrib-jsmath=1.0.1=py_0
  - sphinxcontrib-qthelp=1.0.3=py_0
  - sphinxcontrib-serializinghtml=1.1.4=py_0
  - spyder=4.1.2=py36_0
  - spyder-kernels=1.9.0=py36_0
  - sqlite=3.31.1=h5c1f38d_1
  - tblib=1.6.0=py_0
  - testpath=0.4.4=py_0
  - tk=8.6.8=ha441bb4_0
  - toolz=0.10.0=py_0
  - tornado=6.0.4=py36h1de35cc_1
  - traitlets=4.3.3=py36_0
  - typed-ast=1.4.1=py36h1de35cc_0
  - typing_extensions=3.7.4.1=py36_0
  - ujson=1.35=py36h1de35cc_0
  - urllib3=1.25.8=py36_0
  - watchdog=0.10.2=py36h1de35cc_0
  - wcwidth=0.1.9=py_0
  - webencodings=0.5.1=py36_1
  - wheel=0.34.2=py36_0
  - wrapt=1.12.1=py36h1de35cc_1
  - wurlitzer=2.0.0=py36_0
  - xz=5.2.5=h1de35cc_0
  - yaml=0.1.7=hc338f04_2
  - yapf=0.28.0=py_0
  - zeromq=4.3.1=h0a44026_3
  - zict=2.0.0=py_0
  - zipp=2.2.0=py_0
  - zlib=1.2.11=h1de35cc_3
  - zstd=1.3.7=h5bba6e5_0
prefix: /Users/username/opt/anaconda3/envs/dask-spyder

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ccordoba12commented, Jul 6, 2020

@mmann1123, it hasn’t been released yet but it’ll be available this week for sure.

0reactions
mmann1123commented, Jul 6, 2020

Same issue on Linux 20.14. Sorry to be naive, but how do I upgrade to 4.1.4 if its not available in conda-forge yet?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to handle large datasets in Python with Pandas and Dask
While Pandas is perfect for small to medium-sized datasets, larger ones are problematic. In this article, I show how to deal with large...
Read more >
Dask Best Practices - Dask documentation
This is a short overview of Dask best practices. This document specifically focuses on best practices that are shared among all of the...
Read more >
Optimized ways to Read Large CSVs in Python - Medium
Dask seems to be the fastest in reading this large CSV without crashing or slowing down the computer. Wow! How good is that?!!...
Read more >
Why does Dask perform so slower while multiprocessing ...
In your example, dask is slower than python multiprocessing, because you don't specify the scheduler, so dask uses the multithreading ...
Read more >
update conda environment
Update individual packages, for example spyder: conda update spyder. ... use: conda install -c conda-forge tpot xgboost dask dask-ml scikit-mdr skrebate.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found