pythonseleniumvisual-studio-codevirtualenv

Visual Studio Code don't find selenium


I created a virtualenv in python and then installed with all modules needed to my project.

requests certifi beatifulsoap4 ...

If i run the program in the integrated terminal in visual studio code, it works fine. But If use de command "Run Code" - CTRL+Alt+N - in visual studio code I get the follow error

from selenium import webdriver
ImportError: No module named selenium

I already changed the python path to point to my virtualenv but problem persist.

{
    "files.autoSave": "afterDelay",
    "python.pythonPath": "env/bin/python3"
}

If i change my code to not use selenium, then the "Run Code" command works fine (eveen with others imports)


Solution

  • I have the same problem, Selenium was installed but Visual Studio was not able to import it. In Laymen's term:

    The thing is Selenium is installed but VS Code can't access it, and you need link both them.

    That's how I solved it.

    If you still get an error, open your command-line and install selenium on your PC. Previously we installed it only in our virtual environment.