5

I am currently running python programs in virtualenv but how can I run using visual studio code especially when run/debug is clicked. (Ubuntu)

First I need to be inside the environement this is what I run from terminal source ~/home/python/bin/activate and then python test.py where python is pointing to python3.5 in virtualenv

Basically I want to debug by using breakpoints.

3
  • 1
    Not an answer to your question but Scrapy has some interactive debugging functionality that may be useful for you. Commented May 3, 2017 at 10:44
  • @VMRuiz scrapy i can somehow manage but checking with the virtualenv concept Commented May 3, 2017 at 10:49
  • Possible duplicate of Use Virtualenv with Python with Visual Studio Code in Ubuntu Commented Mar 16, 2018 at 15:42

3 Answers 3

2

please edit launch.json Add Configuration

{
            "name": "Attach (Remote Debug)",
            "type": "python",
            "request": "attach",
            "localRoot": "${workspaceRoot}",
            "remoteRoot": "${workspaceRoot}",
            "port": 3000,
            "secret": "my_secret",
            "host": "localhost"
},

Follow link: https://code.visualstudio.com/docs/editor/debugging

Sign up to request clarification or add additional context in comments.

3 Comments

but how to be in the environment. I have updated the question
Welcome to SO. Please read this how-to-answer to follow the SO guidelines to provide a quality answer..
Check this answer: stackoverflow.com/questions/37642045/… as this represents 2018
2

Assuming you are using the donjayamanne.python plugin for Visual Studio Code you can set this in the User or Workspace Settings file (settings.json):

"python.pythonPath": "~/home/python/bin/python"

You can access the settings file in Visual Studio Code using File -> Preferences -> Settings.

Comments

1

Here is explained how you can run Visual Studio Code with Python https://code.visualstudio.com/docs/languages/python

EDIT1:

Windows - Python Virtual Environment And PYTHONPATH with Visual Studio Code: https://www.youtube.com/watch?v=AfvuK7US_9s

EDIT2: Ubuntu - http://dacrook.com/setting-up-python-and-virtual-environments-in-visual-studio-code-on-ubuntu/

2 Comments

link doesn't say about virtualenv concept
The link for ubuntu now points to a Bitcoin website. Please always give an explanation instead of just liking. Websites are not permanent.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.