Альтаир - Проблемы с настройкой - PullRequest
1 голос
/ 21 марта 2020

У меня есть только четыре дня опыта python. Я использую последнюю версию Anaconda 1.9.2;

Я пытаюсь запустить altair, для этого я следовал официальной установке Инструкции :

conda install -c conda-forge altair vega_datasets

Использование Навигатор Coda - среды, которые я вижу правильно установленными: Altair (4.0.1), vega (2.6.0) и наборы данных vega (0.8.0);

Я проверил все зависимости, упомянутые на Altair Github и вручную установил некоторые, которых не хватало (ie m2r и flake 8)

Однако, запустив пример графика в блокноте jupyter;

import altair as alt
import pandas as pd

# for the notebook only (not for JupyterLab) run this command once per session
alt.renderers.enable('notebook')

source = pd.DataFrame({
    'a': ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I'],
    'b': [28, 55, 43, 91, 81, 53, 19, 87, 52]
})

alt.Chart(source).mark_bar().encode(
    x='a',
    y='b'
)

вывод:

---------------------------------------------------------------------------
NoSuchEntryPoint                          Traceback (most recent call last)
~\Anaconda3\lib\site-packages\altair\utils\plugin_registry.py in _enable(self, name, **options)
    133             try:
--> 134                 ep = entrypoints.get_single(self.entry_point_group, name)
    135             except entrypoints.NoSuchEntryPoint:

~\Anaconda3\lib\site-packages\entrypoints.py in get_single(group, name, path)
    216 
--> 217     raise NoSuchEntryPoint(group, name)
    218 

NoSuchEntryPoint: No 'notebook' entry point found in group 'altair.vegalite.v4.renderer'

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
<ipython-input-2-5584a45a74ac> in <module>
      3 
      4 # for the notebook only (not for JupyterLab) run this command once per session
----> 5 alt.renderers.enable('notebook')
      6 
      7 source = pd.DataFrame({

~\Anaconda3\lib\site-packages\altair\utils\plugin_registry.py in enable(self, name, **options)
    169         if name is None:
    170             name = self.active
--> 171         return PluginEnabler(self, name, **options)
    172 
    173 

~\Anaconda3\lib\site-packages\altair\utils\plugin_registry.py in __init__(self, registry, name, **options)
     23         self.options = options
     24         self.original_state = registry._get_state()
---> 25         self.registry._enable(name, **options)
     26 
     27     def __enter__(self):

~\Anaconda3\lib\site-packages\altair\utils\plugin_registry.py in _enable(self, name, **options)
    135             except entrypoints.NoSuchEntryPoint:
    136                 if name in self.entrypoint_err_messages:
--> 137                     raise ValueError(self.entrypoint_err_messages[name])
    138                 else:
    139                     raise

ValueError: 
To use the 'notebook' renderer, you must install the vega package
and the associated Jupyter extension.
See https://altair-viz.github.io/getting_started/installation.html
for more information.

I обнаружил: Как заставить Альтаира работать с Jupyter Notebook , который говорит мне понизить Vega до 1,3

Это ошибка:

UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:

Specifications:

  - vega==1.3 -> python[version='>=2.7,<2.8.0a0|>=3.5,<3.6.0a0|>=3.6,<3.7.0a0']

Your python: python=3.7

If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.

Я думаю, это имеет смысл, так как кажется, что ответ на этот вопрос связан с более ранним выпуском altair;

Мне не хватает пакета "vega" и связанного расширения Jupyter ?

1 Ответ

0 голосов
/ 21 марта 2020

Удалить строку

alt.renderers.enable('notebook')

Это больше не требуется в Altair 4.0 или новее. Вам нужно будет перезапустить среду выполнения, чтобы изменения вступили в силу.

При желании вы можете использовать средство визуализации ноутбука, включив эту строку, и оно будет работать до тех пор, пока у вас установлена ​​самая последняя версия * 1006. * пакет установлен (в настоящее время версия 3.2). Запустите

pip install -U vega

, чтобы обновить его. Это не будет доступно в conda-forge, пока этот запрос на извлечение не будет объединен.

...