When I tried to actually execute the sample code of web scraping using a library called selenium,

When I write import selenium, I get the error "unresolved import selenium".

I have downloaded selenium with pip, but I don't know how to handle it.

No module named'selenium'
Corresponding source code
import selenium
What I tried


I tried various things with reference to such sites, but it doesn't work very well.

At the command prompt
pip install selenium
After entering, what comes out is

Requirement already satisfied: selenium in c: \ users \ minat \ appdata \ local \ programs \ python \ python38 \ lib \ site-packages (3.141.0)
Requirement already satisfied: urllib3 in c: \ users \ minat \ appdata \ local \ programs \ python \ python38 \ lib \ site-packages (from selenium) (1.25.10)

So, I think that the installation itself has been completed.

Also, if you enter the following in visual studio and execute it,

import sys, pprint
pprint.pprint (sys.path)
['F: \\ Program Folder \\ Python \\ webLogin',
 'F: \\ Program folder \\ Python \\ webLogin',
 'F: \\ Program Files (x86) \\ Microsoft Visual'
 'Studio \\ Shared \\ Python37_64 \\ python37.zip',
 'F: \\ Program Files (x86) \\ Microsoft Visual Studio \\ Shared \\ Python37_64 \\ DLLs',
 'F: \\ Program Files (x86) \\ Microsoft Visual Studio \\ Shared \\ Python37_64 \\ lib',
 'F: \\ Program Files (x86) \\ Microsoft Visual Studio \\ Shared \\ Python37_64',
 'C: \\ Users \\ minat \\ AppData \\ Roaming \\ Python \\ Python37 \\ site-packages',
 'F: \\ Program Files (x86) \\ Microsoft Visual'
 'Studio \\ Shared \\ Python37_64 \\ lib \\ site-packages']

It has become.
Indeed, c: \ users \ minat \ appdata \localI haven't seen \ programs \ python \ python38 \ lib \ site-packages, so I added it to the user's environment variable (?) With the name PYTHONPATH.

However, it has not been improved and the situation is as follows. (I also tried rebooting.)

Personally, there is a difference between python37 and python38, so I wondered if there was something, but I didn't know what to do with it.

Thank you.

Supplementary information (FW/tool version, etc.)


I don't know if it's related, but I had a little development using a library called requests before, but at that time it was loaded normally. When I opened the .sln file, I got an error when importing like selenium.
All I did today was pip --upgrade to install selenium.

>>At the command prompt
py -3.7 -m pip list
What happens if that happens?

It contained the string selenium 3.141.0.
Requests 2.24.0 existed as well.

It was the same even if I changed -3.7 to 3.8 and executed it.

  • Answer # 1

    Since it was an inappropriate answer, I will request deletion.

  • Answer # 2

    I don't think it's a straightforward approach, but I solved it myself.

    [Direct attack]
    It seems that you can use it by installing each library from "Python environment" of visual studio (button like present box on the right side of the frame "Python 3.x (64bit)" on the center of the screen).
    However, in my environment, even though libraries such as selenium are already displayed, when I run it, I get a no module'selenium' error.

    [Method solved this time]
    I was playing around with it
    Tools->Options->Python->General->"Ignore system-wide PYTHONPATH variable"
    If you uncheck the checkbox, it will be loaded correctly.
    To be honest, what do you mean? .. It feels like that, but this time I will end here.
    Thank you to everyone for their advice.