I have a LXD container with a python virtualenv in it. I’d like vscode on my host machine to use this virtualenv. So I mounted it and now I can see the virtualenv directory on my host machine and I can even activate it on my host. But vscode won’t work with it returning the following:
2023-05-18 16:42:38.353 [info] Experiment 'pythonPromptNewFormatterExt' is active
2023-05-18 16:42:38.353 [info] Experiment 'pythonPromptNewToolsExt' is active
2023-05-18 16:42:38.353 [info] Experiment 'pythonSurveyNotification' is active
2023-05-18 16:42:38.353 [info] VS Code was launched from an activated environment: 'venv', selecting it as the interpreter for workspace.
2023-05-18 16:42:38.353 [info] Test server listening.
2023-05-18 16:42:38.589 [info] > ./venv/bin/python -I ~/.vscode/extensions/ms-python.python-2023.8.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.8.0/pythonFiles/interpreterInfo.py
2023-05-18 16:42:38.703 [warning] [Error: Command failed: /home/omar/Documents/code/hexr/venv/bin/python -I /home/omar/.vscode/extensions/ms-python.python-2023.8.0/pythonFiles/get_output_via_markers.py /home/omar/.vscode/extensions/ms-python.python-2023.8.0/pythonFiles/interpreterInfo.py
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH = (not set)
program name = '/home/omar/Documents/code/hexr/venv/bin/python'
isolated = 1
environment = 0
user site = 0
import site = 1
sys._base_executable = '/home/omar/Documents/code/hexr/venv/bin/python'
sys.base_prefix = '/usr'
sys.base_exec_prefix = '/usr'
sys.executable = '/home/omar/Documents/code/hexr/venv/bin/python'
sys.prefix = '/usr'
sys.exec_prefix = '/usr'
sys.path = [
'/usr/lib/python38.zip',
'/usr/lib/python3.8',
'/usr/lib/lib-dynload',
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007f89c1575740 (most recent call first):
<no Python frame>
at ChildProcess.exithandler (node:child_process:409:12)
at ChildProcess.emit (node:events:513:28)
at maybeClose (node:internal/child_process:1112:16)
at Socket.<anonymous> (node:internal/child_process:470:11)
at Socket.emit (node:events:513:28)
at Pipe.<anonymous> (node:net:757:14)] {
code: 1,
killed: false,
signal: null,
cmd: '/home/omar/Documents/code/hexr/venv/bin/python -I /home/omar/.vscode/extensions/ms-python.python-2023.8.0/pythonFiles/get_output_via_markers.py /home/omar/.vscode/extensions/ms-python.python-2023.8.0/pythonFiles/interpreterInfo.py'
}
2023-05-18 16:42:38.712 [info] > ./venv/bin/python ~/.vscode/extensions/ms-python.python-2023.8.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.8.0/pythonFiles/interpreterInfo.py
2023-05-18 16:42:38.727 [error] [Error: Command failed: /home/omar/Documents/code/hexr/venv/bin/python /home/omar/.vscode/extensions/ms-python.python-2023.8.0/pythonFiles/get_output_via_markers.py /home/omar/.vscode/extensions/ms-python.python-2023.8.0/pythonFiles/interpreterInfo.py
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH = (not set)
program name = '/home/omar/Documents/code/hexr/venv/bin/python'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = '/home/omar/Documents/code/hexr/venv/bin/python'
sys.base_prefix = '/usr'
sys.base_exec_prefix = '/usr'
sys.executable = '/home/omar/Documents/code/hexr/venv/bin/python'
sys.prefix = '/usr'
sys.exec_prefix = '/usr'
sys.path = [
'/usr/lib/python38.zip',
'/usr/lib/python3.8',
'/usr/lib/lib-dynload',
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007feadb07b740 (most recent call first):
<no Python frame>
at ChildProcess.exithandler (node:child_process:409:12)
at ChildProcess.emit (node:events:513:28)
at maybeClose (node:internal/child_process:1112:16)
at Socket.<anonymous> (node:internal/child_process:470:11)
at Socket.emit (node:events:513:28)
at Pipe.<anonymous> (node:net:757:14)] {
code: 1,
killed: false,
signal: null,
cmd: '/home/omar/Documents/code/hexr/venv/bin/python /home/omar/.vscode/extensions/ms-python.python-2023.8.0/pythonFiles/get_output_via_markers.py /home/omar/.vscode/extensions/ms-python.python-2023.8.0/pythonFiles/interpreterInfo.py'
}
2023-05-18 16:42:39.987 [info] Starting Pylance language server.
Is it that vscode doesn’t play nicely with LXD?
For reference I’ve created a lxc profile using this script. Which mounts my home directory so that I can access it in the container and so that the container can write to it.