Exporting to PNG; phantomjs error
See original GitHub issueWindows 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:
- Created 6 years ago
- Comments:12 (10 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.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.
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.