# Plotly MapBox not working in my notebook

**URL:** <https://community.plotly.com/t/plotly-mapbox-not-working-in-my-notebook/17138>\
**Category:** 📊 Plotly Python\
**Created:** [December 19, 2018, 5:49pm UTC](https://community.plotly.com/t/plotly-mapbox-not-working-in-my-notebook/17138 "2018-12-19T17:49:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![willtscott](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/willtscott/32/5081_2.png) [@willtscott](https://community.plotly.com/u/willtscott)\
**Post date:** [December 19, 2018, 5:49pm UTC](https://community.plotly.com/t/plotly-mapbox-not-working-in-my-notebook/17138/1 "2018-12-19T17:49:23Z")

</div>

Hi, I am trying to use Mapbox with Plotly in a [Python notebook on Kaggle.](https://www.kaggle.com/willtscott/dashboard-notebook-oakland-service-requests)

I am getting the following (very long) error, even when I run the example code on [plotly here.](https://plot.ly/python/scattermapbox/)

I have a Mapbox account and am using my public token, but I haven’t done much other setup on Mapbox. My Basic Template is Public, as well.

What am I missing here?

Thanks!

**tl;dr**  
This seems to be an http connection error between plotly and mapbox

```
---------------------------------------------------------------------------
gaierror Traceback (most recent call last)
/opt/conda/lib/python3.6/site-packages/urllib3/connection.py in _new_conn(self)
    140 conn = connection.create_connection(
--> 141 (self.host, self.port), self.timeout, **extra_kw)
    142 

/opt/conda/lib/python3.6/site-packages/urllib3/util/connection.py in create_connection(address, timeout, source_address, socket_options)
     59 
---> 60 for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
     61 af, socktype, proto, canonname, sa = res

/opt/conda/lib/python3.6/socket.py in getaddrinfo(host, port, family, type, proto, flags)
    744 addrlist = []
--> 745 for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
    746 af, socktype, proto, canonname, sa = res

gaierror: [Errno -3] Temporary failure in name resolution

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)
    600 body=body, headers=headers,
--> 601 chunked=chunked)
    602 

/opt/conda/lib/python3.6/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    345 try:
--> 346 self._validate_conn(conn)
    347 except (SocketTimeout, BaseSSLError) as e:

/opt/conda/lib/python3.6/site-packages/urllib3/connectionpool.py in _validate_conn(self, conn)
    849 if not getattr(conn, 'sock', None): # AppEngine might not have `.sock`
--> 850 conn.connect()
    851 

/opt/conda/lib/python3.6/site-packages/urllib3/connection.py in connect(self)
    283 # Add certificate verification
--> 284 conn = self._new_conn()
    285 

/opt/conda/lib/python3.6/site-packages/urllib3/connection.py in _new_conn(self)
    149 raise NewConnectionError(
--> 150 self, "Failed to establish a new connection: %s" % e)
    151 

NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f4995e17160>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution

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)
    448 retries=self.max_retries,
--> 449 timeout=timeout
    450 )

/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)
    638 retries = retries.increment(method, url, error=e, _pool=self,
--> 639 _stacktrace=sys.exc_info()[2])
    640 retries.sleep()

/opt/conda/lib/python3.6/site-packages/urllib3/util/retry.py in increment(self, method, url, response, error, _pool, _stacktrace)
    387 if new_retry.is_exhausted():
--> 388 raise MaxRetryError(_pool, url, error or ResponseError(cause))
    389 

MaxRetryError: HTTPSConnectionPool(host='plot.ly', port=443): Max retries exceeded with url: /clientresp (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f4995e17160>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))

During handling of the above exception, another exception occurred:

ConnectionError Traceback (most recent call last)
/opt/conda/lib/python3.6/site-packages/plotly/api/v1/utils.py in request(method, url, **kwargs)
     81 try:
---> 82 response = requests.request(method, url, **kwargs)
     83 except RequestException as e:

/opt/conda/lib/python3.6/site-packages/requests/api.py in request(method, url, **kwargs)
     59 with sessions.Session() as session:
---> 60 return session.request(method=method, url=url, **kwargs)
     61 

/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)
    532 send_kwargs.update(settings)
--> 533 resp = self.send(prep, **send_kwargs)
    534 

/opt/conda/lib/python3.6/site-packages/requests/sessions.py in send(self, request, **kwargs)
    645 # Send the request
--> 646 r = adapter.send(request, **kwargs)
    647 

/opt/conda/lib/python3.6/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    515 
--> 516 raise ConnectionError(e, request=request)
    517 

ConnectionError: HTTPSConnectionPool(host='plot.ly', port=443): Max retries exceeded with url: /clientresp (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f4995e17160>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))

During handling of the above exception, another exception occurred:

PlotlyRequestError Traceback (most recent call last)
<ipython-input-227-723ddee66815> in <module>()
     41 
     42 fig = dict(data=data, layout=layout)
---> 43 ply.iplot(fig, filename='Multiple Mapbox')

/opt/conda/lib/python3.6/site-packages/plotly/plotly/plotly.py in iplot(figure_or_data, **plot_options)
    140 if 'auto_open' not in plot_options:
    141 plot_options['auto_open'] = False
--> 142 url = plot(figure_or_data, **plot_options)
    143 
    144 if isinstance(figure_or_data, dict):

/opt/conda/lib/python3.6/site-packages/plotly/plotly/plotly.py in plot(figure_or_data, validate, **plot_options)
    237 data = fig.get('data', [])
    238 plot_options['layout'] = fig.get('layout', {})
--> 239 response = v1.clientresp(data, **plot_options)
    240 
    241 # Check if the url needs a secret key

/opt/conda/lib/python3.6/site-packages/plotly/api/v1/clientresp.py in clientresp(data, **kwargs)
     33 
     34 url = '{plotly_domain}/clientresp'.format(**cfg)
---> 35 response = request('post', url, data=payload)
     36 
     37 # Old functionality, just keeping it around.

/opt/conda/lib/python3.6/site-packages/retrying.py in wrapped_f(*args, **kw)
     47 @six.wraps(f)
     48 def wrapped_f(*args, **kw):
---> 49 return Retrying(*dargs, **dkw).call(f, *args,**kw)
     50 
     51 return wrapped_f

/opt/conda/lib/python3.6/site-packages/retrying.py in call(self, fn, *args, **kwargs)
    204 
    205 if not self.should_reject(attempt):
--> 206 return attempt.get(self._wrap_exception)
    207 
    208 delay_since_first_attempt_ms = int(round(time.time() * 1000)) - start_time

/opt/conda/lib/python3.6/site-packages/retrying.py in get(self, wrap_exception)
    245 raise RetryError(self)
    246 else:
--> 247 six.reraise(self.value[0], self.value[1], self.value[2])
    248 else:
    249 return self.value

/opt/conda/lib/python3.6/site-packages/six.py in reraise(tp, value, tb)
    691 if value. __traceback__ is not tb:
    692 raise value.with_traceback(tb)
--> 693 raise value
    694 finally:
    695 value = None

/opt/conda/lib/python3.6/site-packages/retrying.py in call(self, fn, *args, **kwargs)
    198 while True:
    199 try:
--> 200 attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
    201 except:
    202 tb = sys.exc_info()

/opt/conda/lib/python3.6/site-packages/plotly/api/v1/utils.py in request(method, url, **kwargs)
     87 status_code = response.status_code if response else None
     88 content = response.content if response else 'No content'
---> 89 raise exceptions.PlotlyRequestError(message, status_code, content)
     90 validate_response(response)
     91 return response

PlotlyRequestError: No message
```

---

<div class="post-metadata">

**Author:** ![jmmease](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jmmease/32/3706_2.png) [@jmmease](https://community.plotly.com/u/jmmease)\
**Post date:** [December 21, 2018, 11:09am UTC](https://community.plotly.com/t/plotly-mapbox-not-working-in-my-notebook/17138/2 "2018-12-21T11:09:05Z")

</div>

Hi @willtscott,

It looks like plotly.py is having trouble communicating with the plot.ly cloud service. Do other, non-mapbox plots work? I’m not that familiar with kaggle’s architecture, but perhaps there is some kind of proxy or firewall issue going on here.

In any case, I’d recommend trying to do your plots in offline mode and see if that works better. Something like:

```python
from plotly.offline import init_notebook_mode, iplot
init_notebook_mode()
fig = ...
iplot(fig)

```

Hope that helps!  
-Jon

---

<div class="post-metadata">

**Author:** ![willtscott](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/willtscott/32/5081_2.png) [@willtscott](https://community.plotly.com/u/willtscott)\
**Post date:** [December 21, 2018, 2:00pm UTC](https://community.plotly.com/t/plotly-mapbox-not-working-in-my-notebook/17138/3 "2018-12-21T14:00:28Z")

</div>

Hi @jmmease,

Thanks for responding.

I eventually got this working and it was a pretty minor fix (as it usually happens 😊 ).

The problem was that at the end I was calling

> ```
> plotly.iplot(fig)
> 
> ```

Instead of

> ```
> iplot(fig)
> 
> ```

So now it’s working great! [Check it out here](https://www.kaggle.com/willtscott/dashboard-notebook-oakland-service-requests) if you’re interested 😉

Thanks,  
Will
