I am using Conda but I believe this problem can be exhibited with other virtual envs. Here is my (simplified) directory heirarchy:
Basically the problem is that when loading my_file.py the wrong python interpreter is located. This can be verified by calling (lsp-python-ms-locate-python "/path/to/venv/zzz_env/src/my_file.py"), which results in /path/to/venv/aaa_env/bin/python. I would expect it to locate the python in the containing environment, namely /path/to/venv/zzz_env/bin/python.
I believe the problem is caused by the lsp-python-ms--dominating-venv-python function, namely:
(defun lsp-python-ms--dominating-venv-python (&optional dir)
"Look for directories that look like venvs"
(let* ((path (or dir default-directory))
(dominating-venv (locate-dominating-file path #'lsp-python-ms--venv-dir)))
(when dominating-venv
(lsp-python-ms--venv-python (lsp-python-ms--venv-dir dominating-venv)))))
Here, the dominating-venv symbol is set to the directory containing the virtual envs, which in my case is ~/venv. The subsequent call to lsp-python-ms--venv-dir picks the first virtual environment in this directory, namely ~/venv/aaa_env.
I believe it should be using the lsp-python-ms--venv-python predicate to locate-dominating-file instead.
Please let me know if my description is not clear or if I can provide any further details. Thanks.