vscode-python: Timeout waiting for debugger connection when using Windows PowerShell

Environment data

  • VS Code version: 1.27.2
  • Extension version (available under the Extensions sidebar): 2018.8.0
  • OS and version: Windows 10 professional release 10.0.17134
  • Python version (& distribution if applicable, e.g. Anaconda): Anaconda 2.7 with Python 3.6.5 conda virtual environment
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): conda
  • Relevant/affected Python packages and their versions: simple helloworld.py no imports

Actual behavior

with a simple hello world - click on debugger selection and green run debug symbol, timeout occurs waiting for debugger connection

Expected behavior

Expecting debugger to connect

Steps to reproduce:

  1. open hello.py file
  2. click on debug spider symbol on left vertical bar

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

##########Linting Output - pylint##########

--------------------------------------------------------------------

Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

 INFO no standard startup: panel is active
console.ts:136 [Extension Host] vscode-icons is active!
console.ts:136 [Extension Host] Git extension API method 'getGitPath' is deprecated.
t.log @ console.ts:136
console.ts:136 [Extension Host] Python Extension: Failed to get conda environment list from conda Error: spawn conda ENOENT
	at _errnoException (util.js:1024:11)
	at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
	at onErrorNT (internal/child_process.js:372:16)
	at _combinedTickCallback (internal/process/next_tick.js:138:11)
	at process._tickCallback (internal/process/next_tick.js:180:9)

OK, opening the ticket, as Brett suggested was a good idea. I had no idea this was the way to get a error message to trigger off of. I searched the error and found a similar issue. There were several questions there which I will answer here.

Conda install location: C:\PyAna2

.vscode/settings.json, what is python.pythonPath value? I find no settings.json file there, extensions only

Conda env list:

(pandas36) C:\Users\Free Agent>conda env list

conda environments:

base C:\PyAna2 pandas36 * C:\PyAna2\envs\pandas36 pdf27 C:\PyAna2\envs\pdf27

> 
(pandas36) C:\Users\Free Agent>conda list
# packages in environment at C:\PyAna2\envs\pandas36:
#
# Name                    Version                   Build  Channel
arrow                     0.12.1                   py36_2    conda-forge
arrow-cpp                 0.9.0               py36_vc14_7  [vc14]  conda-forge
asn1crypto                0.24.0                   py36_0
astroid                   2.0.4                     <pip>
backcall                  0.1.0                    py36_0
binaryornot               0.4.4                      py_1    conda-forge
bleach                    2.1.3                    py36_0
blinker                   1.4                      py36_0
bokeh                     0.12.15                  py36_0
boost-cpp                 1.66.0                   vc14_1  [vc14]  conda-forge
ca-certificates           2018.8.24            ha4d7672_0    conda-forge
certifi                   2018.8.24                py36_0    conda-forge
cffi                      1.11.5           py36h945400d_0
chardet                   3.0.4            py36h420ce6e_1
chardet                   3.0.4                     <pip>
click                     6.7              py36hec8c647_0
cloudpickle               0.5.2                    py36_1
colorama                  0.3.9            py36h029ae33_0
cookiecutter              1.6.0                    py36_0    conda-forge
cryptography              2.2.2            py36hfa6e2cd_0
cycler                    0.10.0           py36h009560c_0
cytoolz                   0.9.0.1          py36hfa6e2cd_0
dask                      0.17.2                   py36_0
dask-core                 0.17.2                   py36_0
datashape                 0.5.4            py36h5770b85_0
decorator                 4.3.0                    py36_0
distributed               1.21.6                   py36_0
entrypoints               0.2.3            py36hfd66bb0_2
et_xmlfile                1.0.1            py36h3d2d736_0
feather-format            0.4.0               py36_vc14_2  [vc14]  conda-forge
freetype                  2.8.1                    vc14_0  [vc14]  conda-forge
future                    0.16.0                   py36_2    conda-forge
gitdb2                    2.0.3                     <pip>
GitPython                 2.1.9                     <pip>
graphviz                  2.38.0                        4    anaconda
heapdict                  1.0.0                    py36_2
html5lib                  1.0.1            py36h047fa9f_0
icc_rt                    2017.0.4             h97af966_0
icu                       58.2                     vc14_0  [vc14]  conda-forge
idna                      2.6              py36h148d497_1
idna                      2.6                       <pip>
intel-openmp              2018.0.0                      8
ipykernel                 4.8.2                    py36_0
ipython                   6.3.1                    py36_0
ipython_genutils          0.2.0            py36h3c5d0ee_0
ipywidgets                7.2.1                    py36_0
isort                     4.3.4                     <pip>
jdcal                     1.4                      py36_0
jedi                      0.12.0                   py36_1
jinja2                    2.10             py36h292fed1_0
jinja2-time               0.2.0                      py_2    conda-forge
jpeg                      9b                       vc14_2  [vc14]  conda-forge
jsonschema                2.6.0            py36h7636477_0
jupyter                   1.0.0                    py36_4
jupyter_client            5.2.3                    py36_0
jupyter_console           5.2.0            py36h6d89b47_1
jupyter_core              4.4.0            py36h56e9d50_0
jupyterthemes             0.19.1                    <pip>
kaggle                    1.3.8                     <pip>
kiwisolver                1.0.1            py36h12c3424_0
lazy-object-proxy         1.3.1                     <pip>
lesscpy                   0.13.0                    <pip>
libpng                    1.6.34                   vc14_0  [vc14]  conda-forge
libsodium                 1.0.16                   vc14_0  [vc14]  conda-forge
libtiff                   4.0.8           vc14h04e2a1e_10  [vc14]  anaconda
lifelines                 0.14.1                    <pip>
llvmlite                  0.22.0           py36ha794a7c_0
locket                    0.2.0            py36hfed976d_1
lxml                      4.2.1                     <pip>
m2w64-gcc-libgfortran     5.3.0                         6
m2w64-gcc-libs            5.3.0                         7
m2w64-gcc-libs-core       5.3.0                         7
m2w64-gmp                 6.1.0                         2
m2w64-libwinpthread-git   5.0.0.4634.697f757               2
markdown                  2.6.11                     py_0    conda-forge
markupsafe                1.0              py36h0e26971_1
matplotlib                2.2.2                    py36_1    conda-forge
mccabe                    0.6.1                     <pip>
missingno                 0.4.0                      py_0    conda-forge
mistune                   0.8.3            py36hfa6e2cd_1
mkl                       2018.0.2                      1
mkl_fft                   1.0.1            py36h452e1ab_0
mkl_random                1.0.1            py36h9258bd6_0
msgpack-python            0.5.6            py36he980bc4_0
msys2-conda-epoch         20160418                      1
multipledispatch          0.5.0                    py36_0
nbconvert                 5.3.1            py36h8dc0fde_0
nbdime                    0.4.1                     <pip>
nbformat                  4.4.0            py36h3a5bc1b_0
networkx                  2.1                      py36_0
notebook                  5.4.1                    py36_0
numba                     0.37.0          np114py36hea3a760_0
numpy                     1.14.2           py36h5c71026_1
oauthlib                  2.1.0                    py36_0
odo                       0.5.1            py36h7560279_0
olefile                   0.45.1                   py36_0
openpyxl                  2.5.3                    py36_0
openssl                   1.0.2p            hfa6e2cd_1000    conda-forge
packaging                 17.1                     py36_0
pandas                    0.22.0           py36h6538335_0
pandas-datareader         0.6.0                     <pip>
pandoc                    1.19.2.1             hb2460c7_1    anaconda
pandocfilters             1.4.2            py36h3ef6317_1
parquet-cpp               1.4.0                    vc14_0  [vc14]  conda-forge
parso                     0.2.0                    py36_0
partd                     0.3.8            py36hc8e763b_0
patsy                     0.5.0                    py36_0
pickleshare               0.7.4            py36h9de030f_0
pillow                    4.2.1            py36hdb25ab2_0    anaconda
pip                       18.0                      <pip>
pip                       9.0.3                    py36_0
plotly                    2.5.1                    py36_0
ply                       3.11                      <pip>
poyo                      0.4.1                      py_1    conda-forge
prompt_toolkit            1.0.15           py36h60b8f86_0
psutil                    5.4.5            py36hfa6e2cd_0
ptvsd                     4.1.3                     <pip>
pweave                    0.30.2                   py36_0    conda-forge
pyarrow                   0.9.0               py36_vc14_1  [vc14]  conda-forge
pycparser                 2.18             py36hd053e01_1
pygments                  2.2.0            py36hb010967_0
pyjwt                     1.6.4                    py36_0
pylint                    2.1.1                     <pip>
pyopenssl                 17.5.0           py36h5b7d817_0
pyparsing                 2.2.0            py36h785a196_1
pyqt                      5.6.0                    py36_2
pysocks                   1.6.8                    py36_0
python                    3.6.5                h0c2934d_0
python-dateutil           2.7.2                    py36_0
pytz                      2018.4                   py36_0
pywinpty                  0.5.1                    py36_0
pyyaml                    3.12             py36h1d1928f_1
pyzmq                     17.0.0           py36hfa6e2cd_1
qt                        5.6.2                    vc14_1  [vc14]  conda-forge
qtconsole                 4.3.1            py36h99a29a9_0
regex                     2018.02.21       py36hfa6e2cd_0
requests                  2.18.4                    <pip>
requests                  2.18.4           py36h4371aae_1
requests-file             1.4.3                     <pip>
requests-ftp              0.3.1                     <pip>
requests-oauthlib         0.8.0                    py36_1
scikit-learn              0.19.1           py36h53aea1b_0
scipy                     1.0.1            py36hce232c7_0
seaborn                   0.8.1            py36h9b69545_0
selenium                  3.11.0                   py36_0
send2trash                1.5.0                    py36_0
setuptools                39.0.1                   py36_0
simplegeneric             0.8.1                    py36_2
simplejson                3.15.0           py36hfa6e2cd_0
sip                       4.19.8           py36h6538335_0
six                       1.11.0           py36h4db2310_1
smmap2                    2.0.3                     <pip>
snappy                    1.1.7                    vc14_1  [vc14]  conda-forge
sortedcontainers          1.5.10                   py36_0
sqlite                    3.22.0                   vc14_0  [vc14]  conda-forge
statsmodels               0.8.0            py36h6189b4c_0
tblib                     1.3.2            py36h30f5020_0
terminado                 0.8.1                    py36_1
testpath                  0.3.1            py36h2698cfe_0
tk                        8.6.7            vc14hb68737d_1  [vc14]  anaconda
toolz                     0.9.0                    py36_0
tornado                   5.0.2                    py36_0
traitlets                 4.3.2            py36h096827d_0
twython                   3.7.0                    py36_0
typed-ast                 1.1.0                     <pip>
urllib3                   1.22             py36h276f60a_0
urllib3                   1.22                      <pip>
vc                        14                   h0510ff6_3
vs2015_runtime            14.0.25123                    3
wcwidth                   0.1.7            py36h3d5aa90_0
webencodings              0.5.1            py36h67c50ae_1
wheel                     0.31.0                   py36_0
whichcraft                0.4.1                      py_1    conda-forge
widgetsnbextension        3.2.1                    py36_0
win_inet_pton             1.0.1            py36he67d7fd_1
wincertstore              0.2              py36h7fe50ca_0
winpty                    0.4.3                    vc14_2  [vc14]  conda-forge
wrapt                     1.10.11                   <pip>
xlwt                      1.3.0            py36h1a4751e_0
yaml                      0.1.7                    vc14_0  [vc14]  conda-forge
zeromq                    4.2.5                    vc14_1  [vc14]  conda-forge
zict                      0.1.3            py36h2d8e73e_0
zlib                      1.2.11                   vc14_0  [vc14]  conda-forge

Path: (pandas36) C:\Users\Free Agent>path PATH=C:\PyAna2\envs\pandas36;C:\PyAna2\envs\pandas36\Library\mingw-w64\bin;C:\PyAna2\envs\pandas36\Library\usr\bin;C:\PyAna2\envs\pandas36\Library\bin;C:\PyAna2\envs\pandas36\Scripts;C:\PyAna2\envs\pandas36\bin;C:\PyAna2;C:\PyAna2\Library\mingw-w64\bin;C:\PyAna2\Library\usr\bin;C:\PyAna2\Library\bin;C:\PyAna2\Scripts;C:\PyAna2\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\HashiCorp\Vagrant\bin;C:\Program Files\PuTTY;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\Git\cmd;C:\Users\Free Agent\AppData\Local\Microsoft\WindowsApps;C:\Users\Free Agent\AppData\Local\GitHubDesktop\bin;C:\Users\Free Agent\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64;C:\Users\Free Agent\AppData\Local\Microsoft\WindowsApps;

So looks like I should start with the fact there is no settings.json file in .vscode?

I also don’t have “conda” on the path, though I do have the conda environments on the path.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 99 (4 by maintainers)

Most upvoted comments

I am experiencing the same issue. All I can add is that this happened directly after installing the latest Windows 10 update.

We believe there are two issues going on (PowerShell not activating fast enough under conda to get the debug command, and a potential issue related to the Windows 10 October 2018 release regardless of environment activation), and due to the amount of comments here it has become hard for us to tell what configurations are leading to failures. If people can provide the following it would be really helpful:

  1. The information listed in the table below (I will update it as people’s responses come in)
  2. A screenshot of the failure (please try to capture your status bar so we can see the Python details as well as the terminal output)

A massive thanks to anyone able to provide details regarding this!

VS Code version Python extension version Windows 10 version ("About your PC") PowerShell version (`$PSVersionTable.PSVersion`) Python version Python environment Environment activation (`"python.terminal.activateEnvironment"`) Debugging works
1.28.1 2018.9.0 Windows 10 1803 PS 5.1 17134 Python 3.7.0 venv `true` Y
1.28.1 2018.9.0 Windows 10 1803 PS 5.1 17134 Python 3.7.0 conda 4.5.11 `false` Y
1.28.1 2018.9.0 Windows 10 1803 PS 5.1 17134 Python 3.7.0 conda 4.5.11 `true` **N**

capture

Thanks – the thread suggested both actions – but I was not smart enough to change the default shell. This helps.

Sent from Mail for Windows 10

From: Jonathan Dobrzeniecki Sent: Thursday, October 11, 2018 10:36 PM To: Microsoft/vscode-python Cc: PCJimmmy; Comment Subject: Re: [Microsoft/vscode-python] Python Timeout waiting for debuggerconnection when using Anaconda (#2732)

Changing to default shell to cmd worked as well. To change default shell:

  1. File -> Preferences -> Settings
  2. Search Terminal
  3. Find a setting with an option to “Edit in settings.json”
  4. Search for “terminal.integrated.shell.windows”
  5. In the window on the right for User Settings change value from PowerShell path to cmd “C:\windows\System32\cmd.exe” — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

Changing shell to command prompt fixed the issue for me.

Hi Everyone, please could you try the following:

  • Change your default shell to command prompt (instead of PowerShell)
  • Disable auto-activation of the terminal. Go into settings.json and add the following setting: "python.terminal.activateEnvironment": false

Reload VS Code, try debugging again. Please upload screenshots of the terminal along with any error messages received.

I’ve had the same timeout issue for about a month now. I tried cloning my conda enviroment and I could debug in the cloned environment, but not in the original. Now, a couple of weeks later, the copied environment also times out when debugging.

I also think the issue is not exclusive to vscode. I’ve tried using PyCharm, and there the debugger stops silently. Likely also timing out, but without the error message.

Thanks to everyone for the help! We’re fairly certain we have eliminated the Windows 10 October 2018 worry and corroborated that this is all because our hack around conda’s lack of PowerShell support just isn’t robust enough based on the APIs that VS Code provides us. We are going to get a fix out that will let you know that conda + PowerShell are not a good combination for debugging (conda should have the support necessary in conda 4.6). We will also make it easy to switch your terminal over to command prompt so that you can still debug with an activated conda environment. Otherwise you can disable environment activation and stick with PowerShell if you prefer while still being able to debug.

for print(“hello”)

Default Shell set to Powershell “python.terminal.activateEnvironment”: true

Debugging works: N - timeout

Default Shell set to Powershell “python.terminal.activateEnvironment”: false

Debugging works: Y

Default Shell set to cmd “python.terminal.activateEnvironment”: false

Debugging works: Y

Default Shell set to cmd “python.terminal.activateEnvironment”: true

Debugging works: Y

launch.json { “name”: “Python: Terminal (integrated)”, “type”: “python”, “request”: “launch”, “program”: “${file}”, “console”: “integratedTerminal”
}, psfalse pstrue

Changing default shell to command prompt sorted the problem for me as well.

I can run the debugger when I change my default shell to command prompt (instead of PowerShell).

Disabling the auto-activation is not necessary for me.

I started having the same problem as everybody else as of today. Had no changes in my environment, was working until yesterday. The only change I can think of was installing the latest Windows 10 update this morning

Hi, I have the exact same issue, debugging is not working. But by right clicking my python file in the explorer and then hitting “Run python file in terminal”, is working. It’s obviously not debugging but certainly python works. I’ve installed python via Anaconda as well.

Downloaded Python 3.6.5 64 bit, installed off the system path, configured to point to that location, and now am able to connect to the debugger.

So that works.

Using that parameter I still had the debugger timeout issue.