ImportError: No module named 'selenium'

后端 未结 18 2227
时光取名叫无心
时光取名叫无心 2020-12-03 00:54

I\'m trying to write a script to check a website. It\'s the first time I\'m using selenium. I\'m trying to run the script on a OSX system. Although I checked in /Library/Pyt

18条回答
  •  情深已故
    2020-12-03 01:00

    I had the exact same problem and it was driving me crazy (Windows 10 and VS Code 1.49.1)

    Other answers talk about installing Selenium, but it's clear to me that you've already did that, but you still get the ImportError: No module named 'selenium'.

    So, what's going on?

    Two things:

    1. You installed Selenium in this folder /Library/Python/2.7/site-packages and selenium-2.46.0-py2.7.egg
    2. But you're probably running a version of Python, in which you didn't install Selenium. For instance: /Library/Python/3.8/site-packages... you won't find Selenium installed here and that's why the module isn't found.

    The solution? You have to install selenium in the same directory to the Python version you're using or change the interpreter to match the directory where Selenium is installed.

    In VS Code you change the interpreter here (at the bottom left corner of the screen)

    Ready! Now your Python interpreter should find the module.

提交回复
热议问题