简体   繁体   English

使用pip安装的selenium但是Python抛出错误

[英]Installed selenium using pip worked but Python throws an error

i am a newbie to python selenium and stumbled into a problem. 我是python selenium的新手,偶然发现了一个问题。

I installed selenium using pip sudo pip install selenium and it worked quiet fine. 我使用pip sudo pip install selenium ,它工作安静。 But when I try to import selenium in my project using from selenium import WebDriver Python throws an error. 但是当我尝试使用from selenium import WebDriver我的项目中from selenium import WebDriver会抛出错误。

I had installed python 2.7 and updated to python 3.7.3. 我安装了python 2.7并更新到python 3.7.3。 I checked the place where pip installed selenium and it is in library/Python/python2.7 . 我检查了pip安装selenium的地方,它在library/Python/python2.7 However there is no folder 3.7.3 where I could drag and drop those files. 但是没有文件夹3.7.3,我可以拖放这些文件。

Betriebssystem: MacOS Mojave Betriebssystem: MacOS Mojave

Python Code: Python代码:

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

Python Fehlermeldung: 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. 我想这与我安装的两个版本的python有关。 But im lost and have no idea how to solve this whole thing:( 但我迷失了,不知道如何解决这整件事:(

Thank you guys in advance. 提前谢谢你们。

to install selenium for Python 2: 为Python 2安装selenium:

python -m pip install selenium

to install selenium for Python 3: 为Python 3安装selenium:

python3 -m pip install selenium

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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