Skip to content

stream to interpreter instead of paths #21473

Closed

Description

I'd like to connect to a python interpreter running inside of a docker container instead of my host machine.

Did some initial experiments by making a script:

exec docker exec python_service python $@

And telling vscode that was my python interpreter. It failed at the first hurdle and by looking in the output I can see that this is due to the fact that the extension calls the python interpreter with file paths which of course don't exist in the container:

2023-06-21 19:34:43.194 [error] [Error: Command failed: /home/abrown/development/projects/dev-service/.vscode/dev-python -I /home/abrown/.vscode-server/extensions/ms-python.python-2023.10.1/pythonFiles/get_output_via_markers.py /home/abrown/.vscode-server/extensions/ms-python.python-2023.10.1/pythonFiles/interpreterInfo.py
python: can't open file '/home/abrown/.vscode-server/extensions/ms-python.python-2023.10.1/pythonFiles/get_output_via_markers.py': [Errno 2] No such file or directory

	at ChildProcess.exithandler (node:child_process:400:12)
	at ChildProcess.emit (node:events:513:28)
	at maybeClose (node:internal/child_process:1093:16)
	at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)] {
  code: 2,
  killed: false,
  signal: null,
  cmd: '/home/abrown/development/projects/dev-service/.vscode/dev-python -I /home/abrown/.vscode-server/extensions/ms-python.python-2023.10.1/pythonFiles/get_output_via_markers.py /home/abrown/.vscode-server/extensions/ms-python.python-2023.10.1/pythonFiles/interpreterInfo.py'
}

So I know it would be theoretically possible to pipe scripts into python instead of using those paths which would make it compatible with docker, but I understand that might be quite the undertaking. Am I totally out to lunch here? Or anyone have any other bright ideas?

Activity

  1. karthiknadig commented on Jun 27, 2023

    @karthiknadig
    Member

    Andrew Brown (@CalianDos) to use the python in a container you should probably be volume mapping your project in the container and use it. You could also use the docker container extension and work with the python in the container.

    Streaming, python scrip to a server has a problem that basic imports wont work. The container will not be able to find modules from your working directory which is not in the container.

    Moving this to discussions as this better fits there.

  2. locked and limited conversation to collaborators on Jun 27, 2023
  3. converted this issue into a discussion #21499 on Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-requestRequest for new features or functionalitytriage-neededNeeds assignment to the proper sub-team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions