JetBrains / lets-plot

Multiplatform plotting library based on the Grammar of Graphics
https://lets-plot.org
MIT License
1.5k stars 47 forks source link

Not working with PyCharm, fails to send plot 500 Error #439

Closed boofhead closed 2 years ago

boofhead commented 2 years ago

running the example code fails

import numpy as np
from lets_plot import *

# Generate random data-points for the demo.
np.random.seed(12)
data = dict(
    cond=np.repeat(['A', 'B'], 200),
    rating=np.concatenate((np.random.normal(0, 1, 200), np.random.normal(1, 1.5, 200)))
)

# Create plot specification.
p = ggplot(data, aes(x='rating', fill='cond')) + ggsize(500, 250) \
    + geom_density(color='dark_green', alpha=.7) + scale_fill_brewer(type='seq') \
    + theme(axis_line_y='blank')

# Display plot in 'SciView'.
p.show()

fails as shown

Error: failed to send plot to http://127.0.0.1:63342
Traceback (most recent call last):
  File "/Users/robinnorthcott/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/212.5284.44/PyCharm.app/Contents/plugins/python/helpers/pycharm_display/datalore/display/display_.py", line 76, in _send_display_message
    urllib_request.urlopen(url, buffer)
  File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 523, in open
    response = meth(req, response)
  File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 632, in http_response
    response = self.parent.error(
  File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 561, in error
    return self._call_chain(*args)
  File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 641, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 500: Internal Server Error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/Users/robinnorthcott/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/212.5284.44/PyCharm.app/Contents/plugins/python/helpers/pycharm_display/datalore/display/display_.py", line 60, in try_empty_proxy
    urllib_request.urlopen(url, buffer)
  File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 523, in open
    response = meth(req, response)
  File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 632, in http_response
    response = self.parent.error(
  File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 561, in error
    return self._call_chain(*args)
  File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 641, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 500: Internal Server Error
alshan commented 2 years ago

Hi Robin, it looks like you haven't installed the lets-plot in sciview plugin for PyCharm.

You also have to enable the 'Scientific mode'. Note, it only available in PyCharm Pro version.

boofhead commented 2 years ago

Hi @alshan

Thanks for getting back to me so fast. I've been trying to install the plugin but it doesn't show up in Market place installing through an ice (I don't see it for any IDE including data spell). Also it looks like recent versions of PyCharm are not supported?

boofhead commented 2 years ago

A bit more digging around and it looks like there are no versions of the plugin that are compatible with current versions of the python IDEs.

alshan commented 2 years ago

This is weird. The plugin is compatible with all versions of PyCharm. As a workaround you can download the latest version (https://plugins.jetbrains.com/plugin/14379-lets-plot-in-sciview/versions/stable/132953) and install it from disk.

I will look in to the issue with the marketplace.

Can't say for Dataspell yet. If Scientific Mode and SciView are present there then plugin will likely work. But to make plots in notebook you don't need the plugin. Just lets-plot in your env. AFAIU Dataspell is all about notebooks in IDE.

boofhead commented 2 years ago

Oh nice, that worked, thanks.

alshan commented 2 years ago

It looks like the issue with the plugin marketplace has been mostly resolved: https://youtrack.jetbrains.com/issue/MP-3625 Should be available for install/update via "Plugins" UI in PyCharm.

alshan commented 2 years ago

Just released the plugin version compatible with DataSpell as well: https://plugins.jetbrains.com/plugin/14379-lets-plot-in-sciview/versions/stable/137514

boofhead commented 2 years ago

Awesome, thanks!