[PYTHON] [Question] No module named'Selenium' in PyCharm

I'm new to programming. I'm just starting to learn Python. I wanted to do web scraping, so I tried scraping using Selenium with reference to a certain site.

When I followed the instructions on the site, it worked fine on Jupyter-notebook. On the other hand, when I try to run the same code in PyCharm, it says No module named'Selenium' and I can't run it.

Why are other modules available in PyCharm? It may be okay if you always use Jupyter-notebook, but I'm curious. I would appreciate your advice.

【environment】 macOS Catalina 10.15.3 Python 3.7.0 (installed with Anaconda)

[Reference site "[Complete version] From environment construction to execution of Selenium on Mac ~ Python & Chrome ~"] https://exture-ri.com/2019/03/22/%E3%80%90%E5%AE%8C%E5%85%A8%E7%89%88%E3%80%91mac%E3%81%A7selenium%E3%82%92%E7%92%B0%E5%A2%83%E6%A7%8B%E7%AF%89%E3%81%8B%E3%82%89%E5%AE%9F%E8%A1%8C%E3%81%BE%E3%81%A7-%E3%80%9Cpythonchrome%E3%80%9C/

--- Below is the code ----

from selenium import webdriver from selenium.webdriver.common.keys import Keys driver = webdriver.Chrome(executable_path = '/Users/xxxxxxxxx/chromedriver') driver.get('https://www.google.co.jp')

elem = driver.find_element_by_name('q') elem.send_keys('liquid biopsy') elem.send_keys(Keys.ENTER) driver.execute_script('window.scrollTo(0, document.body.scrollHeight);') driver.find_element_by_xpath('//[@id="nav"]/tbody/tr/td[4]/a').click() driver.find_element_by_xpath('//[@id="rso"]/div/div/div[1]/div/div/div[1]/a/h3').click()

page_width = driver.execute_script('return document.body.scrollWidth') page_height = driver.execute_script('return document.body.scrollHeight') driver.set_window_size(page_width,page_height) driver.save_screenshot('liquid biopsy_screenshot.png')

Thank you for your cooperation.

Recommended Posts

[Question] No module named'Selenium' in PyCharm
ModuleNotFoundError in poetry: No module named'setuptools'
ModuleNotFoundError in Python: No module named story
Import Error in Python3: No module named'xxxxx'
ModuleNotFoundError: No module named'_bz2' error in pyenv Python
Import cv2 ModuleNotFoundError: No module named'cv2' in python3
ModuleNotFoundError: No module named'py4j'
Remote related settings in pycharm
Resolve No module named tkinter
Mastering type hinting in PyCharm
I get "sanity check" and "No module" errors in import numpy
How to resolve ModuleNotFoundError: No module named XXX in Jupyter Notebook
What to do when ModuleNotFoundError: No module named'XXX' occurs in Python