You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
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.
Activity
karthiknadig commentedon Jun 27, 2023
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.