I installed snowflake-connector-python
in my virtual environment recently using pip install snowflake-connector-python[pandas]==2.7.6
, and it works ok when I run my script from the command line with the virtual environment activated. I set the same virtual environment as VSC interpreter, but trying to run python debugger raises an exeception:
ModuleNotFoundError: No module named 'snowflake.connector'
I also can see that pylance
doesn’t recognize the package either, but all other installed packages are recognized with no problem.
I have seen several questions and answers for similar cases, but none of them have worked for me.
EDIT
I added the parameter python
to the launch.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"python": "${workspaceFolder}/MyVenv/Scripts/python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"args": [
"--env", "dev",
"--argument"
],
"envFile": "${workspaceFolder}/.env",
}
]
}
Getting the same result.
EDIT
I found that the way the module is imported makes pylance
to recognize it, but debugger is still raising the error.
This is the old and new way of importing the module into the code:
Old way
New way
With the new way, code is not highlighted by pylance
, but it is not colored as recognized, though.
4
Answers
The problem was finally solved by doing this:
python -m pip install -r requirements.txt
Usually, when your module can’t be found, your environment hasn’t been activated.
You can try adding the following code to your settings.json after choosing the python interpreter:
I had a similar issue with VSCode as well. What I did is uninstalled the Python extension, reinstalled it and then installed Create Blank Python Module extension (all from Visual Studio Marketplace, of course)
Hope this helps
I had this problem on mac, it was caused by the interpreter in the vs code Python settings being set to the string "python" instead of the string "python3" (on my system running "python" gives an unknown command error)