0

i am a newbie to python selenium and stumbled into a problem.

I installed selenium using pip sudo pip install selenium and it worked quiet fine. But when I try to import selenium in my project using from selenium import WebDriver Python throws an error.

I had installed python 2.7 and updated to python 3.7.3. I checked the place where pip installed selenium and it is in library/Python/python2.7. However there is no folder 3.7.3 where I could drag and drop those files.

Betriebssystem: MacOS Mojave

Python Code:

from selenium import webdriver
driver = webdriver.Chrome('driver/chromedriver')
driver.get('https://www.google.com/')

Python Fehlermeldung:

Traceback (most recent call last):
  File "/Users/christophriepe/Desktop/Integrationstest 
Trainopedia/Integrationstest Trainopedia.py", line 1, in <module>
  from selenium import webdriver
ModuleNotFoundError: No module named 'selenium'

I guess it has something to do with the both versions of python I have installed. But im lost and have no idea how to solve this whole thing:(

Thank you guys in advance.

  • try `sudo pip3 install selenium` - see [https://stackoverflow.com/questions/6587507/how-to-install-pip-with-python-3](https://stackoverflow.com/questions/6587507/how-to-install-pip-with-python-3) if you do not have pip3 - maybe your installation is borked – Patrick Artner May 19 '19 at 11:12
  • if you have two pythons installed then you should have `python`, `python2`, `python3` or even `python2.7`, `python3.7`. The same with `pip`, `pip2`, `pip2.7`, `pip3`, `pip3.7`. In terminal write `pip` and press `tab` to see all commands which start with `pip`. The same with `python` and `tab`. – furas May 19 '19 at 11:17
  • if you don't have `pip3` then you can do `python3 -m pip install ...` – furas May 19 '19 at 11:19
  • Did you make sure the selenium package is added to the project under File>Settings>Project:name_of_project > Project Interpreter? – supputuri May 19 '19 at 15:45

1 Answers1

0

to install selenium for Python 2:

python -m pip install selenium

to install selenium for Python 3:

python3 -m pip install selenium
Corey Goldberg
  • 59,062
  • 28
  • 129
  • 143