I’m trying to run code on Python 3.9.18, which I have chosen as my selected interpreter from my virtual environment. I guess I have so many different versions of Python installed because when I run the code, the errors of not finding packages references 3.10 in the output window but the terminal version of Python is 3.9.18, as desired. I’ve specified python 3.9 in the settings.json file (because I can’t specify 3.9.18) and it says it can’t find yet another package, even though the code editor recognises the package i.e there’s no yellow line under it. I assume the 3.9 in the json file is pointing to yet another version of Python I have installed.
I would love to be able to figure out either how to get everything referencing my specific virtual environment Python (3.9.18) or figure out how to delete all my other python versions so that it has to point to the one I want.
This is the output I got when I specify python 3 in the json file:
[Running] python3 -u "/Users/christhomas/FYP/AccentRecognition-Chris/build_model.py"
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/soundfile.py", line 142, in <module>
raise OSError('sndfile library not found')
OSError: sndfile library not found
I can share screenshots or code if you need to, just not sure what to share yet. Let me know if you need more clarification.
Thanks so much in advance
2
Answers
You’re using Code Runner, which doesn’t use the Python interpreter specified in VSCode. You can either:
To make Code Runner use the Python interpreter selected in VS Code, you need to add the following setting to your settings.json file:
This will make Code Runner run the code in the integrated terminal, which does use the selected Python interpreter.
And you can check your
"code-runner.executorMap"
in your USER settings, it should be like below:By the way, I still suggest you using Run Python File button which provided by Microsoft Python extension.