2

I am using python 3.6 on windows10. I created a virtual environment with:

python -m venv venv

Then I installed a few packages and also installed selenium with the command:

pip install selenium

However when I import selenium, I get an error saying:

ImportError: No module named selenium

when I run the script in cmd. But when I run the same code in VSCode, it gives no errors. I am unable to understand the reason behind this. Also, I tried uninstalling and installing the whole environment again. No changes observed.

Note: I am planning to deploy this project to Heroku. So please give any suggestions you think would be necessary to do when deploying to Heroku.

2 Answers 2

1

To install selenium

C:\Automation\DevelopBranch> pip install selenium

Can you please check Selenium is installed.

C:\Automation\DevelopBranch>pip freeze
selenium==3.141.0
urllib3==1.25.6
You are using pip version 9.0.1, however version 20.0.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' comm
and.

Code:

from selenium import webdriver:
driver = webdriver.Chrome(executable_path=r"path of chromedriver.exe")
driver.maximize_window()
wait = WebDriverWait(driver, 20)
driver.get("https://www.google.com")
Sign up to request clarification or add additional context in comments.

1 Comment

Yes, I checked with pip freeze, selenium is installed.
1

I am very sorry for this... but it just worked by running it with:

python main.py

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.