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

用户在尝试使用Selenium与PhantomJS进行网页自动化时遇到了问题。系统返回了关于'/lib/ld-linux.so.2: bad ELF interpreter: No such file or directory'的错误,表明可能是一个64位与32位软件不匹配的问题。此外,还出现了'Permission denied'错误,提示'ghostdriver.log'没有写权限。用户尝试更改目录权限和指定日志路径,但问题依然存在。'phantomjs'可执行文件未在PATH中找到,'which phantomjs'命令显示在'/usr/local/bin/'下。解决方案可能涉及确认 PhantomJS 版本与操作系统库的对应,以及确保所有相关文件具有正确的权限设置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值