question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exporting to PNG; phantomjs error

See original GitHub issue

Windows Subsystem Linux Python 3.6.3 Anaconda 64 bit Chrome bokeh = 0.12.14

When saving to a bokeh plot to png I get RuntimeError: PhantomJS is not present in PATH. Try "conda install phantomjs" or "npm install -g phantomjs-prebuilt"

And I saw the issue and this PR.

So I tried running the steps by hand.

>>> from subprocess import Popen
>>> from subprocess import PIPE
>>> phantomjs_path = shutil.which('phantomjs')
>>> phantomjs_path
'/home/solactus/anaconda3/bin/phantomjs'
Popen([phantomjs_path, "--version"], stdout=PIPE, stderr=PIPE)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/solactus/anaconda3/lib/python3.6/subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "/home/solactus/anaconda3/lib/python3.6/subprocess.py", line 1344, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/home/solactus/anaconda3/bin/phantomjs'

And when I looked up the error and try adding ‘sh’ like this:

>>>Popen(['sh', phantomjs_path, "--version"], stdout=PIPE, stderr=PIPE)
<subprocess.Popen object at 0x7fc46df93908>

It doesn’t error out; so I was thinking maybe adding the ‘sh’ to line 67 of bokeh/util/dependencies.py?

Here’s a quick sample code that was taken from the previous issue.

from bokeh.io import export_png
from bokeh.plotting import figure, show

# prepare some data
x = [1, 2, 3, 4, 5]
y = [6, 7, 2, 4, 5]

# create a new plot with a title and axis labels
p = figure(title="simple line example", x_axis_label='x', y_axis_label='y')

# add a line renderer with legend and line thickness
p.line(x, y, legend="Temp.", line_width=2)

export_png(p, filename="plot.png")

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
zbarrycommented, Aug 30, 2019

I was facing the same issue for my python 3.7 environment which was not the root. I was able to solve it by installing phantomjs in the root.

My scenario (which might have been yours) was running a JupyterLab server from one conda environment and the notebook python kernel from another. conda install -c conda-forge Phantomjs in the JupyterLab conda environment instead of the kernel environment solved the problem.

0reactions
PanditPranavcommented, Jun 19, 2019

I was facing the same issue for my python 3.7 environment which was not the root. I was able to solve it by installing phantomjs in the root.

Windows Subsystem Linux Python 3.6.3 Anaconda 64 bit Chrome bokeh = 0.12.14

When saving to a bokeh plot to png I get RuntimeError: PhantomJS is not present in PATH. Try "conda install phantomjs" or "npm install -g phantomjs-prebuilt"

And I saw the issue and this PR.

So I tried running the steps by hand.

>>> from subprocess import Popen
>>> from subprocess import PIPE
>>> phantomjs_path = shutil.which('phantomjs')
>>> phantomjs_path
'/home/solactus/anaconda3/bin/phantomjs'
Popen([phantomjs_path, "--version"], stdout=PIPE, stderr=PIPE)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/solactus/anaconda3/lib/python3.6/subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "/home/solactus/anaconda3/lib/python3.6/subprocess.py", line 1344, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/home/solactus/anaconda3/bin/phantomjs'

And when I looked up the error and try adding ‘sh’ like this:

>>>Popen(['sh', phantomjs_path, "--version"], stdout=PIPE, stderr=PIPE)
<subprocess.Popen object at 0x7fc46df93908>

It doesn’t error out; so I was thinking maybe adding the ‘sh’ to line 67 of bokeh/util/dependencies.py?

Here’s a quick sample code that was taken from the previous issue.

from bokeh.io import export_png
from bokeh.plotting import figure, show

# prepare some data
x = [1, 2, 3, 4, 5]
y = [6, 7, 2, 4, 5]

# create a new plot with a title and axis labels
p = figure(title="simple line example", x_axis_label='x', y_axis_label='y')

# add a line renderer with legend and line thickness
p.line(x, y, legend="Temp.", line_width=2)

export_png(p, filename="plot.png")

I was facing the same issue for my python 3.7 environment which was not the root. I was able to solve it by installing phantomjs in the root.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Phantomjs error preventing export of gtsummary tables for use ...
png file that I can open in RMD, as described here, I get the error, "PhantomJS not found. You can install it with...
Read more >
Bokeh export png/svg - Community Support
Hi, I run Anaconda with python3.6 on Windows 7 from bokeh.io import export_svgs […] export_svgs(p, filename=“plot.svg”) the error is RuntimeError: PhantomJS ...
Read more >
Can't catch phantom's errors in highcharts-export-server
Im using the highcharts-export-server as module in NodeJS. I notice when I get an error from phantom for example:.
Read more >
fmwww.bc.edu/RePEc/bocode/w/webimage.ado
image.pdf) /// phantomjs("/usr/local/bin/phantomjs") rendering an online webpage to PNG . webimage "http://www.google.com", export(.
Read more >
PhantomJS - Scriptable Headless Browser
Monitor page loading and export as standard HAR files. Automate performance analysis using YSlow and Jenkins. Ready to play with PhantomJS? Install and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found