I'm using VS Code on a Mac to write Python code. I've created a virtual environment named 'venv' inside my project folder and opened VS Code in my project folder. I can see the venv folder in the Explorer pane. However, if I install a package into the virtual environment and I try to import the package into a Python module and then run the module, VS Code raises a ModuleNotFound error saying there is no module.
I followed the instructions in the VS Code document Using Python environments in VS Code by opening the Command Palette, choosing Python: Select Interpreter, and then selecting "venv/bin/folder". But when I do that, I get this error:
Failed to set 'pythonPath'. Error: Unable to write into folder settings. Please open the 'my_project' folder settings to correct errors/warnings in it and try again.
What are these "folder settings?" I don't see anything in the document I cited above that talks about a folder setting for my virtual environment directory.
Environment:
VS Code 1.35.1
Python for VS Code 0.2.3
Python 3.7.1
UPDATE
Taking @khuynh advice, I opened settings.json and found one error which was that I tried to comment out a line with "//". I didn't realize that JSON files can't include comments.
After taking that line out, I ran "Python: Select Interpreter" again but this time a tab that says .vscode > settings.json >> code-runner.executorMap.python
at the top appeared. The tab contained the following code:
{
"python.pythonPath": "/usr/local/bin/python3"
"code-runner.executorMap.python": "python3 -u"
}
There is a red squiggly line beneath "code-runner.executorMap.python" and the Problems window below says "Unknown configuration setting." I don't understand what's wrong with this setting.
settings.json
. Try opening up your command palette usingcmd+shift+p
and then type in "settings" and select the option "Preferences: Open Settings (JSON)" and look for any red squiggly lines indicating an error. I'd double check your paths to make sure they are correct as well – Lorolla"python.pythonPath": "/usr/local/bin/python3",
. – Lorolla