Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundled Python interpreter not being used in debugger #909

Open
savvn001 opened this issue Apr 12, 2023 · 6 comments
Open

Bundled Python interpreter not being used in debugger #909

savvn001 opened this issue Apr 12, 2023 · 6 comments
Labels
Not a bug Everything works as intended, not a bug.

Comments

@savvn001
Copy link

savvn001 commented Apr 12, 2023

OS: macOS 13.3, M1 MBA
VSCode version:
Version: 1.77.2 (Universal)
Commit: e344f1f539a80912a0e9357cec841f36ce97a4e2
Date: 2023-04-06T10:12:31.126Z (6 days ago)
Electron: 19.1.11
Chromium: 102.0.5005.196
Node.js: 16.14.2
V8: 10.2.154.26-electron.0
OS: Darwin arm64 22.4.0
Sandboxed: No
CodeLLDB version: v1.9.0
Compiler: clang

Hi, I had a debug configuration using this extension where a Python script was loaded on init. This was added to the debug config:

"initCommands": [
   "command script import path_to_my_python_script.py" 
]

The script imports numpy, now the issue is, I'm getting a ModuleNotFoundError: No module named 'numpy' when I start the debugger. Previously this was all working fine because I'd gone to "LLDB Command Prompt" and installed the package. I did the "LLDB Command Prompt" command again and did pip list. It seems the package numpy and others I installed are still there, great. But why can't the debugger find it on launch?
If I comment out the initCommands, and start the debugger, i tried to find what interpreter it had loaded by using these commands:

?/py os.__file__
"/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/os.py"
?/py print(sys.executable)
/Users/myself/.vscode/extensions/vadimcn.vscode-lldb-1.9.0/adapter/codelldb

If I go back to "LLDB Command Prompt" and do the same commands:

(lldb) script sys.executable
'/Users/myself/.vscode/extensions/vadimcn.vscode-lldb-1.9.0/lldb/bin/lldb'
(lldb) script os.__file__
'/Users/myself/.vscode/extensions/vadimcn.vscode-lldb-1.9.0/lldb/lib/python3.9/os.py'

So I'm not sure what's going on here. It looks like when the debugger is started, it's not using the same python interpreter as when I do "LLDB Command Prompt" because otherwise it would have the numpy package installed. Can this be overridden somehow?

@vadimcn
Copy link
Owner

vadimcn commented Apr 12, 2023

@vadimcn vadimcn closed this as not planned Won't fix, can't repro, duplicate, stale Apr 12, 2023
@vadimcn vadimcn added the Not a bug Everything works as intended, not a bug. label Apr 12, 2023
@savvn001
Copy link
Author

savvn001 commented Apr 12, 2023

Hi, sorry but I may be mis understanding. Why is another python interpreter being used when I start the debugger vs when I run the LLDB: Command Prompt command in VSCode? Is that by design?

@vadimcn
Copy link
Owner

vadimcn commented Apr 12, 2023

Ah, sorry, misread the report. The debugger should be using the bundled Python, but I guess system Python somehow managed to take precedence. (Did macos recently upgrade to Python 3.9?)

@vadimcn vadimcn reopened this Apr 12, 2023
@savvn001
Copy link
Author

Ah might that be it? That Python3.9 that is being used, looks like some system Python that was installed recently, I've been doing some xcode development recently and I think it was created around that time. Does this extension look for some environment variable or something when the debugger starts?

Could that be overridden with some flags on init as a quick workaround?

@vadimcn
Copy link
Owner

vadimcn commented Apr 13, 2023

Try 'pip install --user numpy'. In this case it shouldn't matter which Python gets used.

@savvn001
Copy link
Author

savvn001 commented Apr 13, 2023

Doesn't solve the issue unfourtunately. If I go to LLDB: Command Prompt command and do:

(lldb) pip list --user
Package             Version
------------------- -------
contourpy           1.0.7
cycler              0.11.0
fonttools           4.39.3
importlib-resources 5.12.0
kiwisolver          1.4.4
matplotlib          3.7.1
numpy               1.23.5
packaging           23.0
pandas              1.5.1
Pillow              9.5.0
plotly              5.11.0
pyparsing           3.0.9
python-dateutil     2.8.2
pytz                2022.6
six                 1.16.0
tenacity            8.1.0
zipp                3.15.0

I can see all my needed packages are installed.
If I do 'pip install --user numpy'. It will say requirements already satisfied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Not a bug Everything works as intended, not a bug.
Projects
None yet
Development

No branches or pull requests

2 participants