python - Plotly:无法与本地 orca 服务器进程通信,即使服务器进程似乎正在运行
问题描述
当我将一个绘图图形渲染到文件时,如下所示:
import plotly.graph_objects as go
def produce_graph(graph, data_dir):
figure = go.Figure()
[...]
figure.write_image("output_file.png")
我收到以下错误:
Traceback (most recent call last):
File "/Users/brunorijsman/cascade-python/env/lib/python3.7/site-packages/plotly/io/_orca.py", line 1559, in to_image
figure=fig_dict, format=format, scale=scale, width=width, height=height
File "/Users/brunorijsman/cascade-python/env/lib/python3.7/site-packages/retrying.py", line 49, in wrapped_f
return Retrying(*dargs, **dkw).call(f, *args, **kw)
File "/Users/brunorijsman/cascade-python/env/lib/python3.7/site-packages/retrying.py", line 212, in call
raise attempt.get()
File "/Users/brunorijsman/cascade-python/env/lib/python3.7/site-packages/retrying.py", line 247, in get
six.reraise(self.value[0], self.value[1], self.value[2])
File "/Users/brunorijsman/cascade-python/env/lib/python3.7/site-packages/six.py", line 696, in reraise
raise value
File "/Users/brunorijsman/cascade-python/env/lib/python3.7/site-packages/retrying.py", line 200, in call
attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
File "/Users/brunorijsman/cascade-python/env/lib/python3.7/site-packages/plotly/io/_orca.py", line 1474, in request_image_with_retrying
raise OSError("522: client socket timeout")
OSError: 522: client socket timeout
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "study/make_graphs.py", line 169, in <module>
main()
File "study/make_graphs.py", line 166, in main
produce_graph(graph, args.data_dir)
File "study/make_graphs.py", line 70, in produce_graph
figure.write_image(output_file_name)
File "/Users/brunorijsman/cascade-python/env/lib/python3.7/site-packages/plotly/basedatatypes.py", line 2824, in write_image
return pio.write_image(self, *args, **kwargs)
File "/Users/brunorijsman/cascade-python/env/lib/python3.7/site-packages/plotly/io/_orca.py", line 1767, in write_image
fig, format=format, scale=scale, width=width, height=height, validate=validate
File "/Users/brunorijsman/cascade-python/env/lib/python3.7/site-packages/plotly/io/_orca.py", line 1591, in to_image
info=status_str
ValueError:
For some reason plotly.py was unable to communicate with the
local orca server process, even though the server process seems to be running.
Please review the process and connection information below:
orca status
-----------
state: running
executable: /usr/local/bin/orca
version: 1.2.1
port: 65465
pid: 90478
command: ['/usr/local/bin/orca', 'serve', '-p', '65465', '--plotly', '/Users/brunorijsman/cascade-python/env/lib/python3.7/site-packages/plotly/package_data/plotly.min.js', '--graph-only', '--mathjax', 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js']
我还尝试渲染到 .png 文件和 .jpeg 文件,在这些情况下我也得到完全相同的错误。
将图形渲染到浏览器可以正常工作:
figure.show()
我已经尝试添加以下内容,但没有任何区别:
plotly.io.orca.ensure_server()
time.sleep(10)
解决方案
作为这个问题
你应该设置超时禁用
# Disable the orca response timeout.
import plotly.io._orca
import retrying
unwrapped = plotly.io._orca.request_image_with_retrying.__wrapped__
wrapped = retrying.retry(wait_random_min=1000)(unwrapped)
plotly.io._orca.request_image_with_retrying = wrapped
推荐阅读
- java - javac:无效的目标版本:13
- c# - 有条件地将列中的不同值保存到列表中
- java - Java 并发 hashmap 缺失值
- java - Eclipse JUnit 调试模式在暂停/没有我踩踏时终止
- wpf - 如何制作只有特殊类型的 ItemsControl?
- css - css中的2列布局(订购项目)
- compiler-errors - 在 Solaris_x86 上构建 OpenSSL 时,Assembler 报告非法助记符
- python - 用空间扩散因子对 Fitzhugh-Nagumo 模型进行数值求解
- macros - Common Lisp 宏中的闭包
- azure - Azure Invoke-AzVMRunCommand -