简体   繁体   中英

Unable to import 'selenium' pylint(import-error) (solution)

I had this error while I was working on my assignment using python 3.7 in Visual Studio Code . I tried to comment in some previous stackoverflow posts but it doesn't allow me to comment. So I'm sharing the solution I found in this post.

After searching for a solution I came up with the following, using also steps from this link.

  1. Create virtual environment (venv) in the same folder your python file is located C:\\YourFolderPathHere>python3 -m venv nameOfYourVenv
  2. Activate your python virtual environment C:\\YourFolderPathHere>nameOfYourVenv\\Scripts\\activate.bat
  3. Make sure selenium and pylint are installed within this virtual environment
    (nameOfYourVenv) C:\\YourFolderPathHere>pip install selenium
    (nameOfYourVenv) C:\\YourFolderPathHere>pip install pylint
  4. Launch VS Code from cmd
    (nameOfYourVenv) C:\\YourFolderPathHere>code .

Other solutions weren't helpful for me but this worked so I hope it'll be useful for you as well. :)

In my case it was a bit different. My vscode's interpreter was pointing to another version of python. To change the python3 interpreter, open command palette(ctrl+shift+p) and search for, Python : Select Interpreter . Now change that to the correct path and it is good to go.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM