0
我跟着this link,現在當我輸入phan
,然後選項卡(\t
)它會自動完成phantomJS。使用python在linux上運行phantomjs
然而,如果我跑phantomJS -v
或phantomJS --version
我得到:
bash: /usr/local/bin/phantomjs: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
此外,如果我嘗試運行:
>>> from selenium import webdriver
>>> driver = webdriver.PhantomJS()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
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'
>>>
如果我嘗試按照this I get:
>>> import os
>>> driver = webdriver.PhantomJS(service_log_path=os.path.devnull)
Exception AttributeError: "'Service' object has no attribute 'log_file'" in <bound method Service.__del__ of <selenium.webdriver.phantomjs.service.Service object at 0x7f182ec13690>> ignored
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
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.
>>>
是我的硒/ phatnomjs安裝有適當的權利?
我創建了一個目錄/home/ec2-user/temp
並設置:
chmod 777 /home/ec2-user/temp
然而
>>> from selenium import webdriver
>>> driver = webdriver.PhantomJS(service_log_path='/home/ec2-user/temp/ghostdriver.log')
產量:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
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.
如果我型我which phantomjs
得到:
$ which phantomjs
/usr/local/bin/phantomjs
你確定大寫字母嗎?它通常是'phantomjs'而不是'phantomJS'。輸入'which phantomjs'來查看它的安裝位置。 –
@ArtjomB。我更新了這個問題。 –
您是否通過npm安裝了PhantomJS?檢查它是否是一個符號鏈接或實際可執行文件的sh封裝器 –