Visual Studio Code doesn´t recognise an installed module

Viewed 51

I have a project and I need a module which I previously installed in the cmd with pip install. Somehow, (it´s not the first module that had this problem) even though if I check the installation in Visual Stuido it says it´s correct, when I try to use the module, it doesn´t appear to be installed (you can see so in the screenshots). I researched a little bit on the internet and most of the people says it´s a problem with virtual enviroments, but I haven´t created any, so I believe this is not the case (but i´m not quite sure, i´m kinda new into programming) checking module installation installed module not working

1 Answers

I recommend you to start a virtualenv on your source repository like below, and install the library that do you need, pyautogui:

pip install virtualenv
virtualenv venv
source venv/bin/activate
pip install pyautogui

Then, after started the virtualenv, do you can configure your VSCode workspace settings. Do you need to create a folder named .vscode/ at the source project with the settings.json file inside him. The file content is like this:

{
    "python.pythonPath": "<PATH_TO_YOUR_VENV_HERE>/bin/python",
    "editor.formatOnSave": true,
    "editor.formatOnType": true,
    "python.linting.lintOnSave": true,
    "python.linting.flake8Enabled": true,
    "python.linting.pylintEnabled": true,
    "python.linting.pylintArgs": ["--load-plugins", "pylint_django"],
    "python.linting.enabled": true,
    "editor.rulers": [80],
    "editor.tabSize": 4,
    "prettier.singleQuote": true,
    "editor.defaultFormatter": "ms-python.python",
    "python.formatting.provider": "autopep8"
}
  

With your venv activated, do you need to install the libs autopep8 and flake8 with pip:

pip install autopep8
pip install flake8

Then, restart the VSCode.

I hope help you.

Related