python调用linux驱动_使用Python在Linux上运行phantomjs

I followed this link and now when I type phan and then tab (\t) it does autocomplete to phantomJS.

Yet if I run phantomJS -v or phantomJS --version I get:

bash: /usr/local/bin/phantomjs: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory

Additionally if I try to run:

>>> from selenium import webdriver

>>> driver = webdriver.PhantomJS()

Traceback (most recent call last):

File "", line 1, in

File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/phantomjs/webdriver.py", line 50, in __init__

service_args=service_args, log_path=service_log_path)

File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/phantomjs/service.py", line 50, in __init__

service.Service.__init__(self, executable_path, port=port, log_file=open(log_path, 'w'))

IOError: [Errno 13] Permission denied: 'ghostdriver.log'

>>>

If I try to follow this I get:

>>> import os

>>> driver = webdriver.PhantomJS(service_log_path=os.path.devnull)

Exception AttributeError: "'Service' object has no attribute 'log_file'" in > ignored

Traceback (most recent call last):

File "", line 1, in

File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/phantomjs/webdriver.py", line 51, in __init__

self.service.start()

File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 69, in start

os.path.basename(self.path), self.start_error_message)

selenium.common.exceptions.WebDriverException: Message: 'phantomjs' executable needs to be in PATH.

>>>

Is my selenium/phatnomjs installed with the proper rights?

I created a directory /home/ec2-user/temp and set:

chmod 777 /home/ec2-user/temp

Yet

>>> from selenium import webdriver

>>> driver = webdriver.PhantomJS(service_log_path='/home/ec2-user/temp/ghostdriver.log')

Yields:

Traceback (most recent call last):

File "", line 1, in

File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/phantomjs/webdriver.py", line 51, in __init__

self.service.start()

File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 69, in start

os.path.basename(self.path), self.start_error_message)

selenium.common.exceptions.WebDriverException: Message: 'phantomjs' executable needs to be in PATH.

If I type which phantomjs I get:

$ which phantomjs

/usr/local/bin/phantomjs

解决方案

It very much sounds like a 64 vs 32 bits issue.

To find out whats the version of your ubuntu, you can run

$ uname -i

x86_64

Then make sure to download the correct version of phantom

Also make sure your lib are corresponding to the version of your OS.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值