The exact script runs as expected on my own computer, but I get some not understandable error messages when I try to run it on Pythonanywhere.
This is my script:
import chart_studio
import chart_studio.plotly as py
import plotly.express as px
chart_studio.tools.set_credentials_file(username=myusername, api_key=mykey)
chart_studio.tools.set_config_file(world_readable=True, sharing='public')
fig = px.scatter(x=[0, 1, 2, 3, 4], y=[0, 1, 4, 9, 16])
py.plot(fig, filename='test.html', auto_open=False, link=True)
This should make a html file named test.html in https://chart-studio.plotly.com/, but it does not. Instead I get the following error:
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/urllib3/connectionpool.py", line 594, in urlopen
self._prepare_proxy(conn)
File "/usr/lib/python3.8/site-packages/urllib3/connectionpool.py", line 805, in _prepare_proxy
conn.connect()
File "/usr/lib/python3.8/site-packages/urllib3/connection.py", line 308, in connect
self._tunnel()
File "/usr/lib/python3.8/http/client.py", line 898, in _tunnel
raise OSError("Tunnel connection failed: %d %s" % (code,
OSError: Tunnel connection failed: 403 Forbidden
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/usr/lib/python3.8/site-packages/urllib3/connectionpool.py", line 637, in urlopen
retries = retries.increment(method, url, error=e, _pool=self,
File "/usr/lib/python3.8/site-packages/urllib3/util/retry.py", line 399, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.plotly.com', port=443): Max retries exceeded with url: /v2/grids (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/trifektum/.local/lib/python3.8/site-packages/chart_studio/api/v2/utils.py", line 172, in request
response = requests.request(method, url, **kwargs)
File "/usr/lib/python3.8/site-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python3.8/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3.8/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3.8/site-packages/requests/adapters.py", line 510, in send
raise ProxyError(e, request=request)
requests.exceptions.ProxyError: HTTPSConnectionPool(host='api.plotly.com', port=443): Max retries exceeded with url: /v2/grids (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden')))
Is this happening because I am using a free account? And I try to access a site (probably dash chart studio) that is not white listed?
But there is more:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/trifektum/202009_spx_vs_sma50.py", line 11, in <module>
py.plot(fig, filename='test.html', auto_open=False, link=True)
File "/home/trifektum/.local/lib/python3.8/site-packages/chart_studio/plotly/plotly.py", line 276, in plot
grid_ops.upload(
File "/home/trifektum/.local/lib/python3.8/site-packages/chart_studio/plotly/plotly.py", line 1087, in upload
file_info = _create_or_overwrite_grid(payload)
File "/home/trifektum/.local/lib/python3.8/site-packages/chart_studio/plotly/plotly.py", line 1550, in _create_or_overwrite_g
rid
res = api_module.create(data)
File "/home/trifektum/.local/lib/python3.8/site-packages/chart_studio/api/v2/grids.py", line 18, in create
return request("post", url, json=body)
File "/usr/lib/python3.8/site-packages/retrying.py", line 49, in wrapped_f
return Retrying(*dargs, **dkw).call(f, *args, **kw)
File "/usr/lib/python3.8/site-packages/retrying.py", line 206, in call
return attempt.get(self._wrap_exception)
File "/usr/lib/python3.8/site-packages/retrying.py", line 247, in get
six.reraise(self.value[0], self.value[1], self.value[2])
File "/usr/lib/python3.8/site-packages/six.py", line 696, in reraise
raise value
File "/usr/lib/python3.8/site-packages/retrying.py", line 200, in call
attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
File "/home/trifektum/.local/lib/python3.8/site-packages/chart_studio/api/v2/utils.py", line 179, in request
raise exceptions.PlotlyRequestError(message, status_code, content)
chart_studio.exceptions.PlotlyRequestError: No message