#906077 plotly: offline drawing missing /usr/lib/python3/dist-packages/plotly/package_data/plotly.min.js

#906077#5
Date:
2018-08-13 22:08:04 UTC
From:
To:
I tested plotly for the first time, and it fail to work.  I started with
an example from <URL: https://plot.ly/python/line-charts/ >, which fail
to work because I do not have login credentials on some cloud service.
As I want my graph to work locally, not depend on some cloud service, I
tried to modify the example to draw using the offline mode.  When I run
the modified script, I get this error:

Traceback (most recent call last):
  File "./infograph", line 35, in <module>
    py.plot(data, filename='line-mode.html')
  File "/usr/lib/python3/dist-packages/plotly/offline/offline.py", line 461, in plot
    get_plotlyjs(),
  File "/usr/lib/python3/dist-packages/plotly/offline/offline.py", line 49, in get_plotlyjs
    plotlyjs = resource_string('plotly', path).decode('utf-8')
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1210, in resource_string
    self, resource_name
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1452, in get_resource_string
    return self._get(self._fn(self.module_path, resource_name))
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1572, in _get
    with open(path, 'rb') as stream:
FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/python3/dist-packages/plotly/package_data/plotly.min.js'

Is there a file missing in the binary package?

This is the script I am using:

#!/usr/bin/python3

import plotly.offline.offline 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 = 'lines',
    name = 'lines'
)
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 = 'markers',
    name = 'markers'
)
data = [trace0, trace1, trace2]
py.plot(data, filename='line-mode.html')

#906077#10
Date:
2018-08-26 19:55:15 UTC
From:
To:

Hi Petter,

Unfortunately the current version in Stable does not work with the offline mode
since only the minified version javascript was provided by upstream which does
not comply with de DFSG §2.
I have uploaded a version (2.1.0+dfsg-1~bpo9+1) with the unminified javascript to
Stretch Backports repository[1], This version works with offline mode

Best Regards

[1]: https://packages.debian.org/source/stretch-backports/plotly

#906077#15
Date:
2023-07-27 11:53:51 UTC
From:
To:
This bug is still present in Debian bookworm.
Package python3-plotly version 5.4.1+dfsg-1

Debian *does* ship the un-minimized javascript and I was able to fix it by

sudo ln -s /usr/share/python3-plotly/plotly.js /usr/lib/python3/dist-packages/plotly/package_data/plotly.min.js
after creating the package_data directory. I don't care currently if the
javascript is minimized or not.

But Debian should really be shipping the minimized Javascript at the
correct location.

My use-case is exporting html from plotly and specifying that the
javascript is not part of the exported html.

Thanks
Ralf Schlatterbeck