Jun-09-2021, 10:01 AM
I hope you can help me persuade the VS Code debugger to use the right environment.
Trying to run this sample file, mintest.py:
I have a settings.json file in the same folder as mintest.py:
When the virtual environment is activated from the terminal mintest.py runs fine from the terminal.
When mintest.py is run from the debugger (F5) I get this error:
Any tips on what I'm doing wrong much appreciated.
Trying to run this sample file, mintest.py:
1 2 |
import numpy import vg |
1 2 3 |
{ "python.pythonPath" : "C:\\Users\\xxxx\\Code\\hearo\\.env\\Scripts\\python" } |
When mintest.py is run from the debugger (F5) I get this error:
Error:Exception has occurred: ModuleNotFoundError
No module named 'numpy'
File "C:\Users\xxxx\Code\hearo\mintest.py", line 1, in <module>
import numpy
I can see from the text added to the terminal by the debugger that it is not using the pythonPath I specified, but using the global python installation (hence the import error).Output:PS C:\Users\xxxx\Code\hearo> C:; cd 'C:\Users\xxxx\Code\hearo\\'; & 'C:\Users\xxxx\AppData\Local\Programs\Python\Python39\python.exe' 'c:\Users\xxxx\.vscode\extensions\ms-python.python-2021.5.842923320\pythonFiles\lib\python\debugpy\launcher' '50817' '--' 'c:\Users\xxxx\Code\hearo\mintest.py'
I have tried:- Putting the python.pythonPath setting in the launch.json file instead. I get the error:
Error:Property python.pythonPath is not allowed. - Selecting the interpreter using Command Palette before running the debugger I get this error: Error:The Python path in your debug configuration is invalid.
Any tips on what I'm doing wrong much appreciated.