简体   繁体   English

为什么我不能在硒中使用PhantomJ

[英]why I can't use the PhantomJs in Selenium

sudo apt-get install selenium
sudo apt-get install phantomjs

I intall the selenium and phantomjs under ubuntu 16.04. 我在ubuntu 16.04下安装了selenium和phantomjs。 But when 但当

from selenium import webdriver 从硒导入webdriver

browser = webdrive.PhantomJs() 浏览器= webdrive.PhantomJs()

Python Interpreter gives the error msg, AttributeError: 'module' object has no attribute 'PhantomJs'. Python解释器给出错误消息msg, AttributeError:'module'对象没有属性'PhantomJs'。 I dont't know what goes wrong. 我不知道出了什么问题。 Can anyone give some advice. 任何人都可以提一些建议。 I will be very grateful for that. 我将非常感谢。

Ubuntu will automatically install selenium for python2 you should install phantomjs for py3 using this command Ubuntu将自动为python2安装selenium,您应该使用此命令为py3安装phantomjs

sudo pip3 install -U selenium sudo pip3 install -U硒

And make sure when you run your script to specify Python interpreter version 3 并确保在运行脚本时指定Python解释器版本3

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

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