3

I am running below code in Jupyter:

import plotly.plotly as py
import plotly.graph_objs as go

# Create random data with numpy
import numpy as np

N = 100
random_x = np.linspace(0, 1, N)
random_y0 = np.random.randn(N)+5
random_y1 = np.random.randn(N)
random_y2 = np.random.randn(N)-5

# Create traces
trace0 = go.Scatter(
    x = random_x,
    y = random_y0,
    mode = 'markers',
    name = 'markers'
)
trace1 = go.Scatter(
    x = random_x,
    y = random_y1,
    mode = 'lines+markers',
    name = 'lines+markers'
)
trace2 = go.Scatter(
    x = random_x,
    y = random_y2,
    mode = 'lines',
    name = 'lines'
)
data = [trace0, trace1, trace2]

# Plot and embed in ipython notebook!
py.iplot(data, filename='scatter-mode')

I got error result as:

/Library/Python/2.7/site-packages/requests/packages/urllib3/util/ssl_.py:315: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning. SNIMissingWarning /Library/Python/2.7/site-packages/requests/packages/urllib3/util/ssl_.py:120: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning /Library/Python/2.7/site-packages/requests/packages/urllib3/util/ssl_.py:120: InsecurePlatformWarning:

A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.

--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) in () 34 35 # Plot and embed in ipython notebook! ---> 36 py.iplot(data, filename='scatter-mode')

/Library/Python/2.7/site-packages/plotly/plotly/plotly.pyc in iplot(figure_or_data, **plot_options) 173 embed_options['height'] = str(embed_options['height']) + 'px' 174 --> 175 return tools.embed(url, **embed_options) 176 177

/Library/Python/2.7/site-packages/plotly/tools.pyc in embed(file_owner_or_url, file_id, width, height) 407 else: 408 url = file_owner_or_url --> 409 return PlotlyDisplay(url, width, height) 410 else: 411 if (get_config_defaults()['plotly_domain']

/Library/Python/2.7/site-packages/plotly/tools.pyc in init(self, url, width, height) 1382 def init(self, url, width, height): 1383 self.resource = url -> 1384 self.embed_code = get_embed(url, width=width, height=height) 1385 super(PlotlyDisplay, self).init(data=self.embed_code) 1386

/Library/Python/2.7/site-packages/plotly/tools.pyc in get_embed(file_owner_or_url, file_id, width, height) 313 "\nRun help on this function for more information." 314 "".format(url, plotly_rest_url)) --> 315 urlsplit = six.moves.urllib.parse.urlparse(url) 316 file_owner = urlsplit.path.split('/')[1].split('~')[1] 317 file_id = urlsplit.path.split('/')[2]

AttributeError: 'Module_six_moves_urllib_parse' object has no attribute 'urlparse'

I have tried everything to fix it via this thread

Attribute Error trying to run Gmail API quickstart in Python

  1. I did the export PYTHONPATH=/Library/Python/2.7/site-packages and make sure I unset it first to blank (yes, that path exists on my Mac).

  2. I updated w3lib (1.13.0) and six (1.10.0)

  3. Jupyter 4.0.6 and Python 2.7.6

What else could go wrong? Please help.

Community
  • 1
  • 1
HP.
  • 19,226
  • 53
  • 154
  • 253

1 Answers1

1

I realized I picked a wrong kernel in Jupyter. So if it is PySpark kernel, it gave me error. If I use Python2 or Python3 kernel, it's fine.

HP.
  • 19,226
  • 53
  • 154
  • 253