Home > front end >  How to get selenium working in VSCode python
How to get selenium working in VSCode python

Time:12-19

Trying to work through tutorial that works in Python using Selenium.

Tried this:

import selenium

Didn't work. Tried to install again:

pip install selenium
Requirement already satisfied: selenium in ./opt/anaconda3/lib/python3.9/site-packages (4.7.2)
Requirement already satisfied: urllib3[socks]~=1.26 in ./opt/anaconda3/lib/python3.9/site-packages (from selenium) (1.26.12)
Requirement already satisfied: certifi>=2021.10.8 in ./opt/anaconda3/lib/python3.9/site-packages (from selenium) (2022.9.24)
Requirement already satisfied: trio~=0.17 in ./opt/anaconda3/lib/python3.9/site-packages (from selenium) (0.22.0)
Requirement already satisfied: trio-websocket~=0.9 in ./opt/anaconda3/lib/python3.9/site-packages (from selenium) (0.9.2)
Requirement already satisfied: sortedcontainers in ./opt/anaconda3/lib/python3.9/site-packages (from trio~=0.17->selenium) (2.4.0)
Requirement already satisfied: attrs>=19.2.0 in ./opt/anaconda3/lib/python3.9/site-packages (from trio~=0.17->selenium) (21.4.0)
Requirement already satisfied: async-generator>=1.9 in ./opt/anaconda3/lib/python3.9/site-packages (from trio~=0.17->selenium) (1.10)
Requirement already satisfied: outcome in ./opt/anaconda3/lib/python3.9/site-packages (from trio~=0.17->selenium) (1.2.0)
Requirement already satisfied: sniffio in ./opt/anaconda3/lib/python3.9/site-packages (from trio~=0.17->selenium) (1.2.0)
Requirement already satisfied: idna in ./opt/anaconda3/lib/python3.9/site-packages (from trio~=0.17->selenium) (3.4)
Requirement already satisfied: exceptiongroup>=1.0.0rc9 in ./opt/anaconda3/lib/python3.9/site-packages (from trio~=0.17->selenium) (1.0.4)
Requirement already satisfied: wsproto>=0.14 in ./opt/anaconda3/lib/python3.9/site-packages (from trio-websocket~=0.9->selenium) (1.2.0)
Requirement already satisfied: PySocks!=1.5.7,<2.0,>=1.5.6 in ./opt/anaconda3/lib/python3.9/site-packages (from urllib3[socks]~=1.26->selenium) (1.7.1)
Requirement already satisfied: h11<1,>=0.9.0 in ./opt/anaconda3/lib/python3.9/site-packages (from wsproto>=0.14->trio-websocket~=0.9->selenium) (0.14.0)

The import still doesn't work. Why? What do I do to get this statement to work?

CodePudding user response:

I got mine to work this way:

Make sure that you are using the correct version of Python in VSCode. Selenium is compatible with Python 2.7, 3.6, 3.7, 3.8, and 3.9.

Check that the selenium package is installed in the correct location. You can use the following command to check the location of the selenium package:

pip show selenium

Suppose the selenium package is installed in a different location than the one specified in your VSCode project's Python interpreter. In that case, you may need to update your project's Python interpreter to point to the correct location.

If you still have issues, you can try uninstalling and reinstalling the selenium package using pip. To uninstall the package, use the following command:

pip uninstall selenium and then running pip install selenium again

  • Related