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.

vscode debugging failure

See original GitHub issue

Summary

Following the tutorial on https://awesome-streamlit.readthedocs.io/en/latest/vscode.html does not work. Streamlit apps can not be started with ptvsd.

Loading the browser on a streamlit app that has ptvsd enabled causes the following exception

ValueError: signal only works in main thread
File "/home/neuron/src/sch/streamlit-test/venv/lib/python3.6/site-packages/streamlit/ScriptRunner.py", line 311, in _run_script exec(code, module.__dict__)
File "/home/neuron/src/sch/streamlit-test/test.py", line 5, in <module> ptvsd.enable_attach(address=('localhost', 5678), redirect_output=True)
File "/home/neuron/src/sch/streamlit-test/venv/lib/python3.6/site-packages/ptvsd/attach_server.py", line 101, in enable_attach ptvsd_enable_attach(address)
File "/home/neuron/src/sch/streamlit-test/venv/lib/python3.6/site-packages/ptvsd/_remote.py", line 64, in enable_attach **kwargs)
File "/home/neuron/src/sch/streamlit-test/venv/lib/python3.6/site-packages/ptvsd/pydevd_hooks.py", line 128, in install daemon = Daemon(**kwargs)
File "/home/neuron/src/sch/streamlit-test/venv/lib/python3.6/site-packages/ptvsd/daemon.py", line 503, in __init__ super(Daemon, self).__init__(wait_for_user, **kwargs)
File "/home/neuron/src/sch/streamlit-test/venv/lib/python3.6/site-packages/ptvsd/daemon.py", line 100, in __init__ self._install_exit_handlers()
File "/home/neuron/src/sch/streamlit-test/venv/lib/python3.6/site-packages/ptvsd/daemon.py", line 425, in _install_exit_handlers self._exithandlers.install()
File "/home/neuron/src/sch/streamlit-test/venv/lib/python3.6/site-packages/ptvsd/exit_handlers.py", line 62, in install self._install_signal_handler()
File "/home/neuron/src/sch/streamlit-test/venv/lib/python3.6/site-packages/ptvsd/exit_handlers.py", line 103, in _install_signal_handler orig[sig] = signal.signal(sig, self._signal_handler)
File "/usr/lib/python3.6/signal.py", line 47, in signal handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))

This is the script that can reproduce the issue:

#!/usr/bin/python3
import streamlit as st

import ptvsd
ptvsd.enable_attach(address=('localhost', 5678), redirect_output=True)
ptvsd.wait_for_attach()
print("PTSVD listening on localhost:5678")

Debug info

  • Streamlit version: Streamlit, version 0.49.0
  • Python version: Python 3.6.8
  • virtualenv
  • OS version: ubuntu 18.04.3 LTS
  • Browser version: Chrome Version 78.0.3904.70 (Official Build) (64-bit)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:8

github_iconTop GitHub Comments

5reactions
tconklingcommented, Dec 2, 2019

Hey @andaag -

I don’t think we’ve tested Streamlit with ptvsd, so I can’t comment on that particular plugin. (The awesome-streamlit project is created by an (awesome!) Streamlit community member, so the doc you’re following doesn’t come from us.)

I use PyCharm for all my Python debugging, so I’m not a VScode expert, but I was able to get a Streamlit debugging session working without any third-party plugins.

I edited my project’s launch.json file (see here for more details on creating that file), and added a new launch configuration:

{
    "name": "Streamlit: Current File (Integrated Terminal)",
    "type": "python",
    "request": "launch",
    "program": "/Users/tim/.local/share/virtualenvs/lib-CDRh8goq/bin/streamlit",
    "args": [
        "run",
        "${file}"
    ],
    "console": "integratedTerminal"
},

The “program” argument here is the path to bin/streamlit within my local virtual environment, so you’ll need to replace it with the correct path for your setup.

The “args” values here are just telling VScode to run streamlit run ${file}, where ${file} gets replaced with the currently active VScode file.

0reactions
anthonymobilecommented, Sep 12, 2022

also on OSX (M1) with python 10.1 and

Read more comments on GitHub >

github_iconTop Results From Across the Web

Debugger fails to launch after upgrading the VS code ... - GitHub
Steps to Reproduce: Go to "Debug" Mode and try to run the debug config on a typescript spec file. Debugger fails to launch....
Read more >
Debugging in Visual Studio Code
To run or debug a simple app in VS Code, select Run and Debug on the Debug start view or press F5 and...
Read more >
Error Debugging in C++ with VS Code - Rollbar
Debugging can be a life-saver when it comes to discovering bugs or errors in your code. In this article you will learn how...
Read more >
VS Code Debugger not working for python - Microsoft Q&A
When VS Code was updated to 1.64.0 it seems to have broken Python debugging. Clicking on "Run Python File" works fine. Clicking on...
Read more >
Debugging failed in Visual Studio Code for both (gdb) launch ...
When I am trying to debug my code by toggling breakpoints, the debugging gets failed for both (Windows) launch and (gdb) launch.
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