我想在我的Ubuntu 16.04系统中为python 2安装selenium webdriver
当我安装Selenium时,我收到以下错误:
Shubham@Shubham-To-be-filled-by-OEM:~$ sudo apt-get update Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB] Hit:2 https://repo.skype.com/deb stable InRelease Hit:3 http://in.archive.ubuntu.com/ubuntu xenial InRelease Get:4 http://in.archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB] Get:5 http://in.archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB] Fetched 323 kB in 8s (38.6 kB/s) Reading package lists... Done Shubham@Shubham-To-be-filled-by-OEM:~$ sudo pip install selenium Traceback (most recent call last): File "/usr/bin/pip", line 9, in from pip import main ImportError: cannot import name main
我该怎么办?
Selenium可以从Ubuntu 16.04及更高版本的默认Ubuntu存储库中获得。 要安装selenium打开终端并输入:
sudo apt install python-selenium # for Python 2.x
和/或
sudo apt install python3-selenium # for Python 3.x
然后键入python
以启动Python解释器, from selenium import webdriver
应该像这样工作:
$ python >>>来自selenium import webdriver
假设路径~/.local/bin
在你的执行路径中,这里是如何安装Firefox webdriver,称为geckodriver:
wget https://github.com/mozilla/geckodriver/releases/download/v0.20.1/geckodriver-v0.20.1-linux64.tar.gz tar xvfz geckodriver-v0.20.1-linux64.tar.gz mv geckodriver ~/.local/bin