0

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 "<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'
>>> 

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 <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. 

>>> 

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 "<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. 

If I type which phantomjs I get:

$ which phantomjs
/usr/local/bin/phantomjs
Community
  • 1
  • 1
jason m
  • 6,519
  • 20
  • 69
  • 122
  • Are you really sure about the capitalization? It's usually `phantomjs` and not `phantomJS`. Type `which phantomjs` to see where it is installed. – Artjom B. Jun 28 '16 at 08:00
  • @ArtjomB. I updated the question. – jason m Jun 28 '16 at 10:53
  • Did you install PhantomJS through npm? Check if it is a symbolic link or sh wrapper around the actual executable – Artjom B. Jun 28 '16 at 12:14
  • No I did what is in the answer to my top link above. It is a symbolic link to another path. – jason m Jun 28 '16 at 12:16
  • You mean you [this](http://stackoverflow.com/a/14267295/1816580)? If so, then this cannot be done for an RPi, because RPi doesn't have an x86 architecture. You would need to use an executable compiled for arm-hf, which [it](https://bitbucket.org/ariya/phantomjs/downloads) doesn't provide. You need to find another method of installing PhantomJS with the proper architecture. – Artjom B. Jun 28 '16 at 14:43
  • Would npm do this properly? – jason m Jun 28 '16 at 14:44
  • No idea if there are appropriate executables for RPi in "phantomjs" or "phantomjs-prebuilt". – Artjom B. Jun 28 '16 at 14:49
  • I will try and post my progress. – jason m Jun 28 '16 at 14:49

2 Answers2

2

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.

Frederic Henri
  • 51,761
  • 10
  • 113
  • 139
0

You can check out this link.

driver = webdriver.PhantomJS(executable_path='Complete path/to/phantomjs.exe')

It worked well for me.

Nandesh
  • 4,437
  • 2
  • 20
  • 26