microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.31k stars 1.18k forks source link

RFE: Support Remote Interpreter #79

Closed DonJayamanne closed 5 years ago

DonJayamanne commented 6 years ago

From @satyenr on May 13, 2016 3:37

The ability to run code on a remote machine is awesome. You can develop on a Windows PC or a Mac while running and debugging on a remote Linux server. PyCharm supports such a feature - https://www.jetbrains.com/help/pycharm/2016.1/configuring-remote-python-interpreters.html.

Having a remote interpreter also helps when the remote machine already has a functional Python environment - possibly managed by someone else - which you don't want to/can't replicate on your local machine.

Copied from original issue: DonJayamanne/pythonVSCode#123

nickjj commented 6 years ago

I would really like to see this too.

When it comes to running Python inside of a Docker container it would be really neat if we could just set:

    "python.pythonPath": "docker-compose exec web /usr/local/bin/python",
    "python.linting.enabled": true,
    "python.linting.flake8Enabled": true,
    "python.linting.flake8Path": "docker-compose exec web /usr/local/bin/flake8",

That above pattern could technically be applied to all extensions, not just Python.

I tried this now and it doesn't find Python even though it's there in the container. In this case web is a container that has Python and all of the app's dependencies installed (including flake8).

nsoufian commented 6 years ago

we like to see this feature as soon as possible , i see that many people waiting for this feature from long period , technologies is moving fast , docker gives us nice dev environnement .... vs code should benefit from it as soon as possible .

DonJayamanne commented 6 years ago

Hi everyone, this is on our roadmap. However before we move into this space there's a lot more engineering work that needs to be done, and we're in the process of doing this amongst other items.

nickjj commented 6 years ago

@DonJayamanne are your engineering efforts being applied specifically to Python or are you looking into ways so that Dockerized runtimes work for all VSCode supported languages?

nffdiogosilva commented 6 years ago

Hello @DonJayamanne, it's been a while since I gave feedback on this issue. I've read that this issue is already on the roadmap, but is there a launch window date for this feature?

Thanks for any feedback in advance.

Regards.

DonJayamanne commented 6 years ago

but is there a launch window date for this feature? Sorry, we don't have any dates yet, we'll keep you posted when this becomes available. FYI - we've been busy working on a new and improved debugger for VS Code, along with resolving a number of intelliense related issues this month. Once we have date I'll be sure to post it in here.

sensharma commented 6 years ago

Hi! Just a great high-five if this starts working! Going to and from between pycharm and vscode and am missing this feature sorely on vscode (I use docker container environments). If I had to vote for one feature addition, this would be it! Being able to go to definition etc.....!!

pardo commented 6 years ago

What I've being doing as a workaround for docker is a symlink to the virtualenv folder inside the container when running my app.

I'm finding the container folder using the process id.

ln -f -s /proc/`pgrep -nf "manage.py runserver"`/root/home/user/virtualenv .venv

then on my workspace settings I've "python.pythonPath": ".venv/bin/python"

sandys commented 6 years ago

+1 on this from us. This is the biggest blocker in moving from pycharm

sensharma commented 6 years ago

@pardo Interesting hack! But even after finding the PID and the symlink, vscode go to definition or peek at definition doesn't seem to work for me. Do these work for you? Thoughts?

valignatev commented 6 years ago

jedi might have issues with symlinks (but I'm not sure 100% of it). So I use sshfs hack which I described somewhere above.

fmunteanu commented 6 years ago

+1 on first post, using a Docker container as remote interpreter is the proper way to go. Conda, MacPorts or any other similar tools will never match the flexibility of a CentOS/Fedora container environment, where you install all your Python rpm package dependencies in a snap.

DXist commented 6 years ago

There is orthogonal approach - move vscode in the container or mutable remote dev server.

I like it because I prefer dev environments on remote servers.

fmunteanu commented 6 years ago

@pardo that is one binary. What about all the import requirements you need on a fairly advanced microservice.

valignatev commented 6 years ago

@DXist it's ok if your remote dev server is on the same local network with your local machine. But in case of a remote server over the Internet typing latency will kill the productivity.

kliyes commented 6 years ago

+1 for the interpreter on docker container

mirkocoric commented 6 years ago

+1 for the general remote interpreter support

nancyru commented 6 years ago

+1 for docker container on remote server

cysio528 commented 6 years ago

+1 for the interpreter on docker container

I work with PHP and Python, till now I used PHPStorm and PyCharm. Recently I started developing PHP projects with VS Code since they are run on my server, but with Python I work with dockers, a lot of libraries are set up in dockers and I need code inspection of imports refering to in-docker libs. Right now I have te renew subscription of Pycharm because VS code lacs of this feature.

nvictor commented 6 years ago

yep, this

dongbixibi commented 6 years ago

+1 for the general remote interpreter support

harre commented 6 years ago

another +1 (from smb whose colleagues are moving to pycharm basically because of their remote python interpreter support)

xfxf commented 6 years ago

+1. Evaluated VSC to see whether I could move over from PyCharm, but without this feature (or something that allows libraries inside of my docker container to be referenced) it's not a viable option over PyCharm right now.

The linters error (due to 'missing' libraries) and code completion/introspection features don't work.

Add this feature and a lot of people will move over.

ikks commented 6 years ago

There is an article for remote debugging, https://vinta.ws/code/remotely-debug-a-python-app-inside-a-docker-container-in-visual-studio-code.html which refers to https://github.com/Microsoft/ptvsd . Maybe some idea from there can be used? Anyone have been able to test Django aswell with deugging from vs code with that approach?

nffdiogosilva commented 6 years ago

I wished the team gave this max priority... :\

ekerazha commented 6 years ago

This is a must-have if you need to run code on a remote server.

sattamjh commented 6 years ago

+1 for the interpreter on docker container

ekerazha commented 6 years ago

However, having to install node.js on the remote server could be a deal breaker. A PyCharm-like approach would be better.

jhotujec commented 6 years ago

+1

ivpal commented 6 years ago

+1

valignatev commented 6 years ago

pytest-xdist uses execnet for running remote tests. Maybe we might use it as well. I hope I'll have time on a weekend to play with this more. anaconda-mode for emacs has ok remote intellisense capabilities, but having common cross-platform basis would be awesome.

amahoneyLIT commented 6 years ago

+++1

douglasbruce88 commented 6 years ago

+1 from me too, would love to use vscode but require an ssh interpreter

joeyew commented 6 years ago

+1 for the interpreter on docker container

KyeRussell commented 6 years ago

As noted earlier can we please stick to constructive informative comments that add to the discussion. This is a very noisy issue to subscribe to because of +1 comments.

jack-guy commented 6 years ago

Does the release of the new standalone Python language server mean this feature is imminent?

b99andla commented 6 years ago

Im also hoping for this @jack-guy! Anyone who knows or has seen anything hinting to this?

cyberbudy commented 6 years ago

+1

TBusen commented 6 years ago

@DonJayamanne have you looked at the Hydrogen package that Atom uses? It connects to a remote Jupyter kernel, it worked great.

Configuration is easy. I’m switching from Atom to VSC and remote interpreter is the one key feature I miss.

qubitron commented 6 years ago

Hi everyone, thank you for all the requests for remote interpreter support! We're currently looking into how best to support this and wanted to learn more about your needs, setup, etc.

If you could all take 3 minutes to fill out this survey it will be a big help to us: https://www.research.net/r/8D3MGDY

NorthIsUp commented 6 years ago

Is there a way to edit my responses? I hit “go” after the first question and apparently that submitted the whole thing. On Thu, Aug 30, 2018 at 13:47 Dan Taylor notifications@github.com wrote:

Hi everyone, thank you for all the requests for remote interpreter support! We're currently looking into how best to support this and wanted to learn more about your needs, setup, etc.

If you could all take 3 minutes to fill out this survey it will be a big help to us: https://www.research.net/r/8D3MGDY

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Microsoft/vscode-python/issues/79#issuecomment-417407776, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHe9EBvfRinjvVJyAovb6-pTk8NPTgNks5uWCUlgaJpZM4QceWL .

qubitron commented 6 years ago

@northisup I’m not seeing that issue when I hit go but you can submit another survey (might need to use incognito) and I’ll try to discard your first one, sorry about the trouble!

pzmosquito commented 6 years ago

@NorthIsUp just scroll up the page.

NorthIsUp commented 6 years ago

Thanks. Incognito worked. On Thu, Aug 30, 2018 at 15:43 Peter Zhang notifications@github.com wrote:

@NorthIsUp https://github.com/NorthIsUp just scroll up the page.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Microsoft/vscode-python/issues/79#issuecomment-417443721, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHe9I2Vbriui2mYqQW7gYYPJsfnZYtSks5uWEBzgaJpZM4QceWL .

ghost commented 6 years ago

@qubitron What is the expected timeframe on this? My pycharm license is about to run out 😜

sandys commented 6 years ago

hi guys, we are actually using VSCode to debug an application running in a Docker VM. It is working brilliantly actually. I will talk from the python perspective, since we use python.

  1. install vscode
  2. install python extension (ctrl+shift+x). install the one called python 2018.7.1 by Microsoft. Reload vscode.
  3. go to debugger (ctrl+shift+d). click the gear button. make it look like this and then restart vscode

unnamed

  1. run flask cli "docker run --net=host --rm -it -e FLASK_APP=wsgi_debug -e FLASK_ENV=local -e REMOTE_DEBUG=true -v$(pwd):/app -p 4001:4001 -p 6000:6000 mypython flask shell"

(its a standard wsgi script)

  1. once flask shell starts, i run the following to start the vscode debug server on the application side

    import ptvsd
    ptvsd.enable_attach( address = ('0.0.0.0', 6000))
    ptvsd.wait_for_attach()
  2. open the debugger (ctrl+shift+d), choose "Python Attach" from dropdown and press green arrow. It will connect to docker . Docker will proceed and uwsgi will start fully.

  3. debugger is active.

We have all moved away from pycharm over the past month.

DXist commented 6 years ago

What about linting against remote python environment?

ghost commented 6 years ago

@sandys This sounds great, but from what I can tell this won't help me run my code on a remote server? With pycharm I can simply SSH to there, and deploy my code. This works great, since I'd also rather not run everything in a docker

sandys commented 6 years ago

my particular comment (and indeed this entire bug) is around remote debugging.

However, what you said should be possible using stuff like - https://marketplace.visualstudio.com/items?itemName=Kelvin.vscode-sshfs however I'm not sure since i dont use it.

On Tue, Sep 4, 2018 at 2:08 PM LaurensHagendoorn notifications@github.com wrote:

@sandys https://github.com/sandys This sounds great, but from what I can tell this won't help me run my code on a remote server? With pycharm I can simply SSH to there, and deploy my code. This works great, since I'd also rather not run everything in a docker

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Microsoft/vscode-python/issues/79#issuecomment-418287352, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEsU9lTgR5nJQsU60DN8OLXwS3RTE-Mks5uXjvmgaJpZM4QceWL .

ghost commented 6 years ago

That looks good, and solves part of the problem, but I actually also want to run/debug the code on that remote machine.