0

I'm trying to use selenium, but can't get python to recognize it.

I installed it first using "pip install selenium" and "pip install webdriver-manager". It is in the folder "C:\Users\{username}\AppData\Local\Programs\Python\Python310\Lib\site-packages\selenium", but I get the error "ModuleNotFoundError: No module named 'selenium'" when I try to import it.(https://i.stack.imgur.com/dVplU.png) (https://i.stack.imgur.com/wiREJ.png)

Here it is shown as installed with the command "pip list" (https://i.stack.imgur.com/QhOu7.png)

I also tried uninstalling it and reinstalling with flags that I saw some people say worked, but it didn't make a difference. (https://i.stack.imgur.com/VTTMU.png)

I only have one python interpreter version installed, 3.10 (so only one python folder, "Python310"). I have pandas in the same site-packages folder which I can import and use no problem.

If anyone knows what the issue might be, please let me know. I can't figure it out for the life of me.

monkey2k
  • 11
  • 3
  • from the first screenshot it looks like Visual Studio Code has the wrong interpreter. You should click on where it says "3.10.9 64-bit (microsoft store)" on the bottom and point it to the python interpreter you *have* installed, the one in "AppData\Local" – mlg556 Feb 08 '23 at 22:30
  • @mlg556 When I tried to change interpreters, only the one labeled (microsoft store) was in the list. I solved the issue by uninstalling that version and reinstalling from the python website. – monkey2k Feb 08 '23 at 23:03

2 Answers2

1

Okay, I solved the issue by completely uninstalling the interpreter which I got from the Microsoft Store and reinstalling it from the official Python website. Now "from selenium import webdriver" works.

monkey2k
  • 11
  • 3
0

Somehow installed in the global scope is not getting recognized within the Virtual Environment of VS Code / PyCharm.


Solution

You need to install Selenium within the Virtual Environment.

Within the Terminal execute the command:

pip install -U selenium
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352