My example :
import plotly
plotly.version
from plotly.offline import iplot, init_notebook_mode
import plotly.graph_objs as go
import plotly.io as pio
import os
import numpy as np
init_notebook_mode(connected=True)
N = 100
x = np.random.rand(N)
y = np.random.rand(N)
colors = np.random.rand(N)
sz = np.random.rand(N)*30
fig = go.Figure()
fig.add_scatter(x=x,
y=y,
mode=âmarkersâ,
marker={âsizeâ: sz,
âcolorâ: colors,
âopacityâ: 0.6,
âcolorscaleâ: âViridisâ
});
iplot(fig)
if not os.path.exists(âimagesâ):
os.mkdir(âimagesâ)
pio.write_image(fig, âimages/fig1.pngâ)
only works on a single user, it is curious because it is with the user that I executed it first.
I installed orca, plotly (the installation is from a docker, everything installed globally, pip install and so on) as it appears on the official page, orca --help in the terminal works for me, without any error.
If I do it in that user if I execute the code correctly, but if I execute it in any other, it does not work and I get the following error :
ConnectionRefusedError Traceback (most recent call last)
/opt/conda/lib/python3.6/site-packages/urllib3/connection.py in _new_conn(self)
170 conn = connection.create_connection(
â> 171 (self._dns_host, self.port), self.timeout, **extra_kw)
172
/opt/conda/lib/python3.6/site-packages/urllib3/util/connection.py in create_connection(address, timeout, source_address, socket_options)
78 if err is not None:
â> 79 raise err
80
/opt/conda/lib/python3.6/site-packages/urllib3/util/connection.py in create_connection(address, timeout, source_address, socket_options)
68 sock.bind(source_address)
â> 69 sock.connect(sa)
70 return sock
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
NewConnectionError Traceback (most recent call last)
/opt/conda/lib/python3.6/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
599 body=body, headers=headers,
â> 600 chunked=chunked)
601
/opt/conda/lib/python3.6/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
353 else:
â> 354 conn.request(method, url, **httplib_request_kw)
355
/opt/conda/lib/python3.6/http/client.py in request(self, method, url, body, headers, encode_chunked)
1238 âââSend a complete request to the server.â""
-> 1239 self._send_request(method, url, body, headers, encode_chunked)
1240
/opt/conda/lib/python3.6/http/client.py in _send_request(self, method, url, body, headers, encode_chunked)
1284 body = _encode(body, âbodyâ)
-> 1285 self.endheaders(body, encode_chunked=encode_chunked)
1286
/opt/conda/lib/python3.6/http/client.py in endheaders(self, message_body, encode_chunked)
1233 raise CannotSendHeader()
-> 1234 self._send_output(message_body, encode_chunked=encode_chunked)
1235
/opt/conda/lib/python3.6/http/client.py in _send_output(self, message_body, encode_chunked)
1025 del self._buffer[:]
-> 1026 self.send(msg)
1027
/opt/conda/lib/python3.6/http/client.py in send(self, data)
963 if self.auto_open:
â> 964 self.connect()
965 else:
/opt/conda/lib/python3.6/site-packages/urllib3/connection.py in connect(self)
195 def connect(self):
â> 196 conn = self._new_conn()
197 self._prepare_conn(conn)
/opt/conda/lib/python3.6/site-packages/urllib3/connection.py in _new_conn(self)
179 raise NewConnectionError(
â> 180 self, âFailed to establish a new connection: %sâ % e)
181
NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f465ce420b8>: Failed to establish a new connection: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
MaxRetryError Traceback (most recent call last)
/opt/conda/lib/python3.6/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
444 retries=self.max_retries,
â> 445 timeout=timeout
446 )
/opt/conda/lib/python3.6/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
637 retries = retries.increment(method, url, error=e, _pool=self,
â> 638 _stacktrace=sys.exc_info()[2])
639 retries.sleep()
/opt/conda/lib/python3.6/site-packages/urllib3/util/retry.py in increment(self, method, url, response, error, _pool, _stacktrace)
397 if new_retry.is_exhausted():
â> 398 raise MaxRetryError(_pool, url, error or ResponseError(cause))
399
MaxRetryError: HTTPConnectionPool(host=âlocalhostâ, port=36785): Max retries exceeded with url: / (Caused by NewConnectionError(â<urllib3.connection.HTTPConnection object at 0x7f465ce420b8>: Failed to establish a new connection: [Errno 111] Connection refusedâ,))
During handling of the above exception, another exception occurred:
ConnectionError Traceback (most recent call last)
/opt/conda/lib/python3.6/site-packages/plotly/io/_orca.py in to_image(fig, format, width, height, scale, validate)
1324 width=width,
-> 1325 height=height)
1326 except OSError as err:
/opt/conda/lib/python3.6/site-packages/retrying.py in wrapped_f(*args, **kw)
48 def wrapped_f(*args, **kw):
â> 49 return Retrying(*dargs, **dkw).call(f, *args, **kw)
50
/opt/conda/lib/python3.6/site-packages/retrying.py in call(self, fn, *args, **kwargs)
211 # get() on an attempt with an exception should cause it to be raised, but raise just in case
â> 212 raise attempt.get()
213 else:
/opt/conda/lib/python3.6/site-packages/retrying.py in get(self, wrap_exception)
246 else:
â> 247 six.reraise(self.value[0], self.value[1], self.value[2])
248 else:
/opt/conda/lib/python3.6/site-packages/six.py in reraise(tp, value, tb)
692 raise value.with_traceback(tb)
â> 693 raise value
694 finally:
/opt/conda/lib/python3.6/site-packages/retrying.py in call(self, fn, *args, **kwargs)
199 try:
â> 200 attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
201 except:
/opt/conda/lib/python3.6/site-packages/plotly/io/_orca.py in request_image_with_retrying(**kwargs)
1231 json_str = json.dumps(request_params, cls=plotly.utils.PlotlyJSONEncoder)
-> 1232 response = requests.post(server_url + â/â, data=json_str)
1233 return response
/opt/conda/lib/python3.6/site-packages/requests/api.py in post(url, data, json, **kwargs)
111
â> 112 return request(âpostâ, url, data=data, json=json, **kwargs)
113
/opt/conda/lib/python3.6/site-packages/requests/api.py in request(method, url, **kwargs)
57 with sessions.Session() as session:
â> 58 return session.request(method=method, url=url, **kwargs)
59
/opt/conda/lib/python3.6/site-packages/requests/sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
511 send_kwargs.update(settings)
â> 512 resp = self.send(prep, **send_kwargs)
513
/opt/conda/lib/python3.6/site-packages/requests/sessions.py in send(self, request, **kwargs)
621 # Send the request
â> 622 r = adapter.send(request, **kwargs)
623
/opt/conda/lib/python3.6/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
512
â> 513 raise ConnectionError(e, request=request)
514
ConnectionError: HTTPConnectionPool(host=âlocalhostâ, port=36785): Max retries exceeded with url: / (Caused by NewConnectionError(â<urllib3.connection.HTTPConnection object at 0x7f465ce420b8>: Failed to establish a new connection: [Errno 111] Connection refusedâ,))
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
in
49
50
â> 51 pio.write_image(fig, âimages/fig1.pngâ)
52
53
/opt/conda/lib/python3.6/site-packages/plotly/io/_orca.py in write_image(fig, file, format, scale, width, height, validate)
1510 width=width,
1511 height=height,
-> 1512 validate=validate)
1513
1514 # Open file
/opt/conda/lib/python3.6/site-packages/plotly/io/_orca.py in to_image(fig, format, width, height, scale, validate)
1340
1341 {info}
-> 1342 ââ".format(info=status_str))
1343 else:
1344 # Reset the status so that if the user tries again, weâll try to
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: /opt/conda/bin/orca
version: 1.2.1
port: 36785
pid: 2935
command: ['/opt/conda/bin/orca', 'serve', '-p', '36785', '--plotly', '/opt/conda/lib/python3.6/site-packages/plotly/package_data/plotly.min.js', '--graph-only', '--mathjax', 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js']
I donât understand why it works for one user and not for the others.
Thanks.