Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 2.7 Compatibility #1317

Closed
thefabnab opened this issue Jan 31, 2019 · 7 comments
Closed

Python 2.7 Compatibility #1317

thefabnab opened this issue Jan 31, 2019 · 7 comments

Comments

@thefabnab
Copy link

Hey folks,

It looks like I'm unable to import altair and I think it may be related to my version of python. I'm stuck using legacy python (python 2.7), and whenever I try and import it I get the following error:

TypeError: 'ellipsis' object is not iterable

I can appreciate that I should be using python 3 but that isn't an option here. My question is, is this error unique to my python version? and if so what version of altair should I roll back to for the time being?

altair v2.3.0 py27_1001 conda-forge

ipython trace:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-1-43bef06448fc> in <module>()
----> 1 import altair as alt

/locus/home/nazamy/test_env/miniconda3/envs/clin_ifx/lib/python2.7/site-packages/altair/__init__.py in <module>()
      2 __version__ = '2.3.0'
      3
----> 4 from .vegalite import *
      5 from . import examples
      6

/locus/home/nazamy/test_env/miniconda3/envs/clin_ifx/lib/python2.7/site-packages/altair/vegalite/__init__.py in <module>()
      1 # flake8: noqa
----> 2 from .v2 import *

/locus/home/nazamy/test_env/miniconda3/envs/clin_ifx/lib/python2.7/site-packages/altair/vegalite/v2/__init__.py in <module>()
      1 # flake8: noqa
      2 from .schema import *
----> 3 from .api import *
      4
      5 from ...datasets import (

/locus/home/nazamy/test_env/miniconda3/envs/clin_ifx/lib/python2.7/site-packages/altair/vegalite/v2/api.py in <module>()
     13 from .data import data_transformers, pipe
     14 from ... import utils, expr
---> 15 from .display import renderers, VEGALITE_VERSION, VEGAEMBED_VERSION, VEGA_VERSION
     16 from .theme import themes
     17

/locus/home/nazamy/test_env/miniconda3/envs/clin_ifx/lib/python2.7/site-packages/altair/vegalite/v2/display.py in <module>()
      2
      3 from ...utils.mimebundle import spec_to_mimebundle
----> 4 from ..display import Displayable
      5 from ..display import default_renderer_base
      6 from ..display import json_renderer_base

/locus/home/nazamy/test_env/miniconda3/envs/clin_ifx/lib/python2.7/site-packages/altair/vegalite/display.py in <module>()
----> 1 from ..utils.display import Displayable, default_renderer_base, json_renderer_base
      2 from ..utils.display import RendererRegistry, HTMLRenderer
      3
      4
      5 __all__ = (

/locus/home/nazamy/test_env/miniconda3/envs/clin_ifx/lib/python2.7/site-packages/altair/utils/display.py in <module>()
     17
     18
---> 19 class RendererRegistry(PluginRegistry[RendererType]):
     20     entrypoint_err_messages = {
     21         'notebook': textwrap.dedent(

/locus/home/nazamy/test_env/miniconda3/envs/clin_ifx/lib/python2.7/site-packages/typing.pyc in __getitem__(self, params)
   1040                     "Too %s parameters for %s; actual %s, expected %s" %
   1041                     ("many" if alen > elen else "few", repr(self), alen, elen))
-> 1042             tvars = _type_vars(params)
   1043             args = params
   1044         return self.__class__(self.__name__,

/locus/home/nazamy/test_env/miniconda3/envs/clin_ifx/lib/python2.7/site-packages/typing.pyc in _type_vars(types)
    277 def _type_vars(types):
    278     tvars = []
--> 279     _get_type_vars(types, tvars)
    280     return tuple(tvars)
    281

/locus/home/nazamy/test_env/miniconda3/envs/clin_ifx/lib/python2.7/site-packages/typing.pyc in _get_type_vars(types, tvars)
    272     for t in types:
    273         if isinstance(t, TypingMeta):
--> 274             t._get_type_vars(tvars)
    275
    276

/locus/home/nazamy/test_env/miniconda3/envs/clin_ifx/lib/python2.7/site-packages/typing.pyc in _get_type_vars(self, tvars)
    800     def _get_type_vars(self, tvars):
    801         if self.__args__:
--> 802             _get_type_vars(self.__args__, tvars)
    803
    804     def _eval_type(self, globalns, localns):

/locus/home/nazamy/test_env/miniconda3/envs/clin_ifx/lib/python2.7/site-packages/typing.pyc in _get_type_vars(types, tvars)
    270
    271 def _get_type_vars(types, tvars):
--> 272     for t in types:
    273         if isinstance(t, TypingMeta):
    274             t._get_type_vars(tvars)

TypeError: 'ellipsis' object is not iterable```
@jakevdp
Copy link
Collaborator

jakevdp commented Jan 31, 2019

Altair is Python 2 compatible – we test Python 2.7 in our continuous integration suite. But this may be an issue with some particular minor release in Python 2.7. For example, this particular error comes up in Python 3.5.2, but not in Python 3.5.3 (see #839)

What exact version of Python 2.7 are you using?

>>> import sys
>>> sys.version_info

@thefabnab
Copy link
Author

thefabnab commented Jan 31, 2019


In [2]: sys.version_info
Out[2]: sys.version_info(major=2, minor=7, micro=15, releaselevel='final', serial=0)

Which I'm assuming means 2.7.15

@jakevdp
Copy link
Collaborator

jakevdp commented Jan 31, 2019

What version of the typing library do you have installed?

import typing
typing.__version__

@jakevdp
Copy link
Collaborator

jakevdp commented Jan 31, 2019

Sorry, that doesn't work. Instead run the bash command

$ python -m pip list | grep typing
typing          3.6.6      

@jakevdp
Copy link
Collaborator

jakevdp commented Jan 31, 2019

I can reproduce the error with typing version 3.5.2 on python 2.7.15. If you upgrade the package to a newer version, I think it should fix your problem:

$ python -m pip install -U typing

@jakevdp
Copy link
Collaborator

jakevdp commented Jan 31, 2019

To prevent this in the future, we should require typing>=3.6 in requirements.txt.

@thefabnab
Copy link
Author

Holy cow, thanks @jakevdp totally works. I will add the requirement to my docs.

jakevdp added a commit to jakevdp/altair that referenced this issue Jan 31, 2019
jakevdp added a commit to jakevdp/altair that referenced this issue Jan 31, 2019
jakevdp added a commit that referenced this issue Jan 31, 2019
MAINT: Add typing package version to requirements.txt (fixes #1317)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants