Search code examples
pythonpython-idle

Python module not found in Visual Studio Code but other IDLE found it


Good day,

I just wanted to install the module mysql.connector. I had a error that said the module wasn't found. I added the path to sys.path and then tried again. Everything is correctly working on any other IDLE for Python.

However the code still gets me the error on Visual Studio Code:

Exception has occurred: ModuleNotFoundError
   No module named 'myslq'
File "C:\Users\nurum\OneDrive\Documents\Visual Studio Code\May2020\App1_Dictionary\MyApp1.py", line 
8, in <module>
   import myslq.connector

Why only on VS Code? Not very familiar with this software, do I need to changes the Settings in it or the problem might lay elsewhere?

I use Windows and the latest version of VS. I found similar question on StackOverflow and the people advice to change the Python environment since the code is using a different Python interpreter for VS Code and IDLE.

However, when I change the environment, I still get the same error, module not found..


Solution

  • Do you use the Terminal on VSCode or the normal F5(run) method? If you use the terminal or run it from cmd/bash it should work. For cmd

    pythonfile.py For bash python pythonfile.py