Python : no module named selenium

后端 未结 2 1347
萌比男神i
萌比男神i 2020-11-22 03:55

After searching the web for hours i didnt yet find an answer to my problem. I am using Python 3.6 and i cant import selenium. I always get the message \"No module named \'se

2条回答
  •  终归单人心
    2020-11-22 04:31

    I'm on VS Code in Windows 10, and here's how I solved it.

    You need to pay attention to where the Python is located (in my case),

    1) C:\Users\_Me_\AppData\Local\Programs\Python\Python38\ 
    

    and where the Python looks for libraries/packages, including the ones installed using pip (again, in my case),

    2) C:\Users\_Me_\AppData\Roaming\Python\Python38\
    

    I don't know why these two locations are different (gotta fix it at some point). It seemed that Python was running from the first location, but it was looking for libraries in the second!:/

    Anyway, since I have limited experience in Python , I just copied the \Lib\site-packages from the first location (including selenium folders) to \site-packages in second one in hopes of solving the issue, which worked out for me!

    How to check for there locations

    1) Open Python CLI, typed the following command:

    which python
    

    2) Open Python CLI, typed the following commands (From this answer):

    >>> import site
    >>> site.USER_SITE
    

    EDIT

    Since this seems a temporary solution, I uninstalled Python and reinstalled it again in a proper directory (other than the default install directory), and now which python and which pip point to the same folder! Problem solved!

提交回复
热议问题