2016-06-28 8 views
0

私はphanと入力してからタブ(\t)を入力すると、phantomJSにオートコンプリートします。this linkに続きました。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 
+0

大文字は本当に確かですか?それは通常「ファントムズ」であり、「ファントムズ」ではありません。どこにphantomjsがインストールされているかを確認するために ''どのファイルを入力しますか '' –

+0

@ArtjomB。私は質問を更新しました。 –

+0

PhantomJSをnpmでインストールしましたか?実際の実行可能ファイルのシンボリックリンクかshラッパーかを確認してください。 –

答えて

2

64ビットと32ビットの問題のように聞こえます。 https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-i686.tar.bz2

  • 64ビット:

    は、あなたのUbuntuのバージョンは、あなたがdownload

    $ uname -i 
    x86_64 
    

    が続いて確認してください

    また、あなたのlibがあなたのOSのバージョンに対応していることを確認してください。

  • 関連する問題