我在
python中导入selenium webdriver时遇到了一些麻烦.只是为了确保:这是我的小脚本:
import selenium
from selenium import webdriver
browser = webdriver.Firefox(executable_path='/Users/Sleeps/Webdrivers/Firefox/geckodriver')
当我跑
来自selenium import webdriver,
我被抛出错误
没有名为’selenium.webdriver.firefox.webdriver’的模块.
我整齐地按照Selenium自己建议的步骤(你可以找到它们here). Nonethelss,我得到了错误.我不知道为什么会这样.我尝试了以下方法:
pip安装硒
python -m pip install -U selenium
sudo pip3安装selenium
无论我用什么,皮普证实
要求已经满足:./ anaconda / lib / python3.5 / site -packages中的selenium
我在Anaconda目录中进一步讨价还价.我似乎在正确的地方有selenium包:/Users/Sleeps/anaconda/lib/python3.5/selenium/webdriver/__init__.py
编辑
我进一步为MacOS安装了最新的gecko驱动程序(你可以找到它here).我将它解压缩到Users / Sleeps / Webdrivers / Firefox /.
我在命令行中运行了PATH = $PATH:/ Users / Sleeps / Webdrivers / Firefox / geckodriver.
从pprint import pprint运行;进口口; import sys; pprint(sys.path中); pprint(os.getenv( “路径”)); pprint(os.getcwd())返回
['',
'/Users/Sleeps/anaconda/lib/python3.5/site-packages/six-1.10.0-py3.5.egg',
'/Users/Sleeps/anaconda/lib/python35.zip',
'/Users/Sleeps/anaconda/lib/python3.5',
'/Users/Sleeps/anaconda/lib/python3.5/plat-darwin',
'/Users/Sleeps/anaconda/lib/python3.5/lib-dynload',
'/Users/Sleeps/anaconda/lib/python3.5/site-packages',
'/Users/Sleeps/anaconda/lib/python3.5/site-packages/Sphinx-1.4.1-py3.5.egg',
'/Users/Sleeps/anaconda/lib/python3.5/site-packages/aeosa',
'/Users/Sleeps/anaconda/lib/python3.5/site-packages/IPython/extensions',
'/Users/Sleeps/.ipython']
'/Library/Frameworks/Python.framework/Versions/2.7/bin:/Users/Sleeps/anaconda/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin'
('/Users/Sleeps/Dropbox/01_Data '
'Science/Kooperation/EX/Automobile‘)
ls -alh返回
total 24
drwxr-xr-x@ 3 Sleeps staff 102B 9 Aug 12:06 .
drwxr-xr-x@ 35 Sleeps staff 1,2K 9 Aug 12:06 ..
-rwxr-xr-x@ 1 Sleeps staff 9,4K 9 Aug 11:59 Test.ipynb
当我从selenium import webdriver运行时,我仍然得到错误.
我怎么能摆脱它?