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

list index out of range exception when importing graph_objs #721

Closed
miken opened this issue Mar 28, 2017 · 12 comments
Closed

list index out of range exception when importing graph_objs #721

miken opened this issue Mar 28, 2017 · 12 comments

Comments

@miken
Copy link

miken commented Mar 28, 2017

Hi, I installed the latest version of plotly today (2.0.6) and ran into the following error with the first import line:

import plotly.graph_objs as go

It gives me the following error:

/usr/local/lib/python2.7/site-packages/plotly/__init__.py in <module>()
     29 from __future__ import absolute_import
     30
---> 31 from plotly import (plotly, dashboard_objs, graph_objs, grid_objs, tools,
     32                     utils, session, offline, colors)
     33 from plotly.version import __version__

/usr/local/lib/python2.7/site-packages/plotly/plotly/__init__.py in <module>()
      8
      9 """
---> 10 from . plotly import (
     11     sign_in,
     12     update_plot_options,

/usr/local/lib/python2.7/site-packages/plotly/plotly/plotly.py in <module>()
     27 from requests.compat import json as _json
     28
---> 29 from plotly import exceptions, files, session, tools, utils
     30 from plotly.api import v1, v2
     31 from plotly.plotly import chunked_requests

/usr/local/lib/python2.7/site-packages/plotly/tools.py in <module>()
     58
     59 ipython_core_display = optional_imports.get_module('IPython.core.display')
---> 60 matplotlylib = optional_imports.get_module('plotly.matplotlylib')
     61 sage_salvus = optional_imports.get_module('sage_salvus')
     62

/usr/local/lib/python2.7/site-packages/plotly/optional_imports.pyc in get_module(name)
     21     if name not in _not_importable:
     22         try:
---> 23             return import_module(name)
     24         except ImportError:
     25             _not_importable.add(name)

/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.pyc in import_module(name, package)
     35             level += 1
     36         name = _resolve_name(name[level:], package, level)
---> 37     __import__(name)
     38     return sys.modules[name]

/usr/local/lib/python2.7/site-packages/plotly/matplotlylib/__init__.py in <module>()
     12 from __future__ import absolute_import
     13
---> 14 from plotly.matplotlylib.renderer import PlotlyRenderer
     15 from plotly.matplotlylib.mplexporter import Exporter

/usr/local/lib/python2.7/site-packages/plotly/matplotlylib/renderer.py in <module>()
     11 import warnings
     12
---> 13 import plotly.graph_objs as go
     14 from plotly.matplotlylib.mplexporter import Renderer
     15 from plotly.matplotlylib import mpltools

/usr/local/lib/python2.7/site-packages/plotly/graph_objs/__init__.py in <module>()
     12 from __future__ import absolute_import
     13
---> 14 from plotly.graph_objs.graph_objs import *  # this is protected with __all__

/usr/local/lib/python2.7/site-packages/plotly/graph_objs/graph_objs.py in <module>()
     32 import six
     33
---> 34 from plotly import exceptions, graph_reference
     35 from plotly.graph_objs import graph_objs_tools
     36

/usr/local/lib/python2.7/site-packages/plotly/graph_reference.py in <module>()
    230
    231
--> 232 @utils.memoize()
    233 def _get_valid_attributes(object_name, parent_object_names):
    234     attributes = get_attributes_dicts(object_name, parent_object_names)

/usr/local/lib/python2.7/site-packages/plotly/utils.pyc in memoize(maxsize)
    490         return result
    491
--> 492     return decorator(_memoize)

/usr/local/lib/python2.7/site-packages/decorator.pyc in decorator(caller, _func)
    256         callerfunc = caller
    257         doc = caller.__doc__
--> 258         fun = getfullargspec(callerfunc).args[0]  # first arg
    259     else:  # assume caller is an object with a __call__ method
    260         name = caller.__class__.__name__.lower()

IndexError: list index out of range

Please advise on how I can fix this.

@miken
Copy link
Author

miken commented Mar 28, 2017

For what it's worth, when I uninstalled 2.0.6 and installed 2.0.0 this issue went away for anyone wanting a quick fix.

@chriddyp
Copy link
Member

Thanks for reporting @miken !

I actually can't reproduce this. @cldougl @Kully can you? I'll leave this issue open for anyone else who might encounter it.

@cldougl
Copy link
Member

cldougl commented Mar 28, 2017

I can't reproduce either. @miken can you let us know how you upgraded the package (i.e. with pip or anaconda?)

@miken
Copy link
Author

miken commented Mar 28, 2017

Sure. I upgraded using pip install plotly --upgrade. I have two computers: with my iMac 27" it looks like the import went just fine with 2.0.6 version. With my MacBook, that's when the error occurred.

I can run pdb; pdb.pm() to send back assigned values from the error stack if that's helpful, e.g., callerfunc returns an empty list in the memoize() decorator. Let me know how I can help.

@Kkevsterrr
Copy link

I'm having the same issue with plotly 2.0.6, and downgrading to 2.0.0 fixed the problem.

File "test.py", line 4, in
import plotly.plotly as py
File "/usr/local/lib/python2.7/site-packages/plotly/init.py", line 31, in
from plotly import (plotly, dashboard_objs, graph_objs, grid_objs, tools,
File "/usr/local/lib/python2.7/site-packages/plotly/plotly/init.py", line 10, in
from . plotly import (
File "/usr/local/lib/python2.7/site-packages/plotly/plotly/plotly.py", line 29, in
from plotly import exceptions, files, session, tools, utils
File "/usr/local/lib/python2.7/site-packages/plotly/tools.py", line 60, in
matplotlylib = optional_imports.get_module('plotly.matplotlylib')
File "/usr/local/lib/python2.7/site-packages/plotly/optional_imports.py", line 23, in get_module
return import_module(name)
File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/init.py", line 37, in import_module
import(name)
File "/usr/local/lib/python2.7/site-packages/plotly/matplotlylib/init.py", line 14, in
from plotly.matplotlylib.renderer import PlotlyRenderer
File "/usr/local/lib/python2.7/site-packages/plotly/matplotlylib/renderer.py", line 13, in
import plotly.graph_objs as go
File "/usr/local/lib/python2.7/site-packages/plotly/graph_objs/init.py", line 14, in
from plotly.graph_objs.graph_objs import * # this is protected with all
File "/usr/local/lib/python2.7/site-packages/plotly/graph_objs/graph_objs.py", line 34, in
from plotly import exceptions, graph_reference
File "/usr/local/lib/python2.7/site-packages/plotly/graph_reference.py", line 232, in
@utils.memoize()
File "/usr/local/lib/python2.7/site-packages/plotly/utils.py", line 492, in memoize
return decorator(_memoize)
File "/usr/local/lib/python2.7/site-packages/decorator.py", line 258, in decorator
fun = getfullargspec(callerfunc).args[0] # first arg
IndexError: list index out of range

@ryecao
Copy link

ryecao commented May 7, 2017

Same issue here

import plotly
Traceback (most recent call last):
File "", line 1, in
File "/Users/ryecao/.pyenv/versions/2.7.11/lib/python2.7/site-packages/plotly/init.py", line 31, in
from plotly import (plotly, dashboard_objs, graph_objs, grid_objs, tools,
File "/Users/ryecao/.pyenv/versions/2.7.11/lib/python2.7/site-packages/plotly/plotly/init.py", line 10, in
from . plotly import (
File "/Users/ryecao/.pyenv/versions/2.7.11/lib/python2.7/site-packages/plotly/plotly/plotly.py", line 29, in
from plotly import exceptions, files, session, tools, utils
File "/Users/ryecao/.pyenv/versions/2.7.11/lib/python2.7/site-packages/plotly/tools.py", line 60, in
matplotlylib = optional_imports.get_module('plotly.matplotlylib')
File "/Users/ryecao/.pyenv/versions/2.7.11/lib/python2.7/site-packages/plotly/optional_imports.py", line 23, in get_module
return import_module(name)
File "/Users/ryecao/.pyenv/versions/2.7.11/lib/python2.7/importlib/init.py", line 37, in import_module
import(name)
File "/Users/ryecao/.pyenv/versions/2.7.11/lib/python2.7/site-packages/plotly/matplotlylib/init.py", line 14, in
from plotly.matplotlylib.renderer import PlotlyRenderer
File "/Users/ryecao/.pyenv/versions/2.7.11/lib/python2.7/site-packages/plotly/matplotlylib/renderer.py", line 13, in
import plotly.graph_objs as go
File "/Users/ryecao/.pyenv/versions/2.7.11/lib/python2.7/site-packages/plotly/graph_objs/init.py", line 14, in
from plotly.graph_objs.graph_objs import * # this is protected with all
File "/Users/ryecao/.pyenv/versions/2.7.11/lib/python2.7/site-packages/plotly/graph_objs/graph_objs.py", line 34, in
from plotly import exceptions, graph_reference
File "/Users/ryecao/.pyenv/versions/2.7.11/lib/python2.7/site-packages/plotly/graph_reference.py", line 232, in
@utils.memoize()
File "/Users/ryecao/.pyenv/versions/2.7.11/lib/python2.7/site-packages/plotly/utils.py", line 492, in memoize
return decorator(_memoize)
File "/Users/ryecao/.pyenv/versions/2.7.11/lib/python2.7/site-packages/decorator.py", line 249, in decorator
fun = getfullargspec(callerfunc).args[0] # first arg
IndexError: list index out of range

@chriddyp
Copy link
Member

I suspect that this issue has to do with the decorator requirement: https://github.com/plotly/plotly.py/blob/master/setup.py#L49

@ryecao @Kkevsterrr @miken - could you run $ pip freeze in the environment that you're installing plotly in and paste in the results? I have a feeling that we need to enforce a specific version of the decorator requirement.

@chriddyp
Copy link
Member

@ryecao @Kkevsterrr @miken - In addition, could you also let me know what version of python you're using? Thanks!

@chriddyp
Copy link
Member

chriddyp commented May 30, 2017

I have successfully replicated the issue with this requirements.txt:

appdirs==1.4.0
Babel==0.9.6
backports.ssl-match-hostname==3.4.0.2
chardet==2.2.1
click==6.7
configobj==4.7.2
cycler==0.10.0
decorator==3.4.0
enum34==1.1.6
Flask==0.12.2
Flask-Compress==1.4.0
Flask-SeaSurf==0.2.2
functools32==3.2.3.post2
iniparse==0.4
IPy==0.75
ipython-genutils==0.2.0
itsdangerous==0.24
Jinja2==2.7.2
jsonpatch==1.2
jsonpointer==1.9
jsonschema==2.6.0
jupyter-core==4.3.0
kitchen==1.1.1
lxml==3.7.2
MarkupSafe==0.11
matplotlib==2.0.0
nbformat==4.3.0
nose==1.3.0
numpy==1.7.1
packaging==16.8
pandas==0.19.2
pandas-datareader==0.4.0
perf==0.1
plotly==2.0.7
prettytable==0.7.2
pycurl==7.19.0
pyliblzma==0.5.3
pyOpenSSL==0.13.1
pyparsing==2.1.10
pyserial==2.6
python-dateutil==1.5
pytz==2016.10
PyYAML==3.10
requests==2.13.0
requests-file==1.4.2
requests-ftp==0.3.1
six==1.10.0
subprocess32==3.2.7
traitlets==4.3.2
urllib3==1.10.2
virtualenv==15.1.0
Werkzeug==0.12.2

@chriddyp
Copy link
Member

It appears the issue is related to decorator<4.0.5. I just tried install decorator from version 3.4.2 upwards. Here is the decorator changelog: https://github.com/micheles/decorator/blob/master/CHANGES.md

Here is how I reproduced the issue:


$ pip install decorator==3.4.2
Collecting decorator==3.4.2
  Downloading decorator-3.4.2.tar.gz
Building wheels for collected packages: decorator
  Running setup.py bdist_wheel for decorator ... done
  Stored in directory: /Users/chriddyp/Library/Caches/pip/wheels/a2/ed/a1/350f269ac214a25a2f0d5d6dafea1ec71cdb9cadc2a7434e0a
Successfully built decorator
Installing collected packages: decorator
Successfully installed decorator-3.4.2
You are using pip version 8.0.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

$ pip install plotly
Collecting plotly
Requirement already satisfied (use --upgrade to upgrade): decorator in ./venv/lib/python2.7/site-packages (from plotly)
Collecting pytz (from plotly)
  Using cached pytz-2017.2-py2.py3-none-any.whl
Collecting requests (from plotly)
  Downloading requests-2.17.3-py2.py3-none-any.whl (87kB)
    100% |████████████████████████████████| 90kB 1.9MB/s
Collecting six (from plotly)
  Using cached six-1.10.0-py2.py3-none-any.whl
Collecting nbformat>=4.2 (from plotly)
  Using cached nbformat-4.3.0-py2.py3-none-any.whl
Collecting idna<2.6,>=2.5 (from requests->plotly)
  Downloading idna-2.5-py2.py3-none-any.whl (55kB)
    100% |████████████████████████████████| 57kB 1.4MB/s
Collecting certifi>=2017.4.17 (from requests->plotly)
  Downloading certifi-2017.4.17-py2.py3-none-any.whl (375kB)
    100% |████████████████████████████████| 376kB 739kB/s
Collecting chardet<3.1.0,>=3.0.2 (from requests->plotly)
  Downloading chardet-3.0.3-py2.py3-none-any.whl (133kB)
    100% |████████████████████████████████| 135kB 875kB/s
Collecting urllib3<1.22,>=1.21.1 (from requests->plotly)
  Downloading urllib3-1.21.1-py2.py3-none-any.whl (131kB)
    100% |████████████████████████████████| 135kB 1.3MB/s
Collecting jupyter-core (from nbformat>=4.2->plotly)
  Using cached jupyter_core-4.3.0-py2.py3-none-any.whl
Collecting jsonschema!=2.5.0,>=2.4 (from nbformat>=4.2->plotly)
  Using cached jsonschema-2.6.0-py2.py3-none-any.whl
Collecting traitlets>=4.1 (from nbformat>=4.2->plotly)
  Using cached traitlets-4.3.2-py2.py3-none-any.whl
Collecting ipython-genutils (from nbformat>=4.2->plotly)
  Using cached ipython_genutils-0.2.0-py2.py3-none-any.whl
Collecting functools32 (from jsonschema!=2.5.0,>=2.4->nbformat>=4.2->plotly)
Collecting enum34 (from traitlets>=4.1->nbformat>=4.2->plotly)
  Using cached enum34-1.1.6-py2-none-any.whl
Installing collected packages: pytz, idna, certifi, chardet, urllib3, requests, six, enum34, ipython-genutils, traitlets, jupyter-core, functools32, jsonschema, nbformat, plotly
Successfully installed certifi-2017.4.17 chardet-3.0.3 enum34-1.1.6 functools32-3.2.3.post2 idna-2.5 ipython-genutils-0.2.0 jsonschema-2.6.0 jupyter-core-4.3.0 nbformat-4.3.0 plotly-2.0.8 pytz-2017.2 requests-2.17.3 six-1.10.0 traitlets-4.3.2 urllib3-1.21.1
You are using pip version 8.0.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

$ python -c "import plotly"
Traceback (most recent call last):
[...]
  File "/Users/chriddyp/tmp/bp/test/venv/lib/python2.7/site-packages/plotly/graph_reference.py", line 232, in <module>
    @utils.memoize()
  File "/Users/chriddyp/tmp/bp/test/venv/lib/python2.7/site-packages/plotly/utils.py", line 492, in memoize
    return decorator(_memoize)
  File "/Users/chriddyp/tmp/bp/test/venv/lib/python2.7/site-packages/decorator.py", line 228, in decorator
    fun = getfullargspec(callerfunc).args[0]  # first arg
IndexError: list index out of range


$ pip install decorator==4.0.0
Collecting decorator==4.0.0
  Downloading decorator-4.0.0-py2.py3-none-any.whl
Installing collected packages: decorator
  Found existing installation: decorator 3.4.2
    Uninstalling decorator-3.4.2:
      Successfully uninstalled decorator-3.4.2
Successfully installed decorator-4.0.0
You are using pip version 8.0.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

$ python -c "import plotly"
Traceback (most recent call last):
[...]
  File "/Users/chriddyp/tmp/bp/test/venv/lib/python2.7/site-packages/plotly/graph_reference.py", line 232, in <module>
    @utils.memoize()
  File "/Users/chriddyp/tmp/bp/test/venv/lib/python2.7/site-packages/plotly/utils.py", line 492, in memoize
    return decorator(_memoize)
  File "/Users/chriddyp/tmp/bp/test/venv/lib/python2.7/site-packages/decorator.py", line 247, in decorator
    fun = getfullargspec(callerfunc).args[0]  # first arg
IndexError: list index out of range

$ pip install decorator==4.0.1
Collecting decorator==4.0.1
python   Downloading decorator-4.0.1-py2.py3-none-any.whl
Installing collected packages: decorator
  Found existing installation: decorator 4.0.0
    Uninstalling decorator-4.0.0:
      Successfully uninstalled decorator-4.0.0
-Successfully installed decorator-4.0.1
You are using pip version 8.0.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

$ python -c "import plotly"
Traceback (most recent call last):
[...]
  File "/Users/chriddyp/tmp/bp/test/venv/lib/python2.7/site-packages/plotly/graph_reference.py", line 232, in <module>
    @utils.memoize()
  File "/Users/chriddyp/tmp/bp/test/venv/lib/python2.7/site-packages/plotly/utils.py", line 492, in memoize
    return decorator(_memoize)
  File "/Users/chriddyp/tmp/bp/test/venv/lib/python2.7/site-packages/decorator.py", line 249, in decorator
    fun = getfullargspec(callerfunc).args[0]  # first arg
IndexError: list index out of range

$ pip install decorator==4.0.2
Collecting decorator==4.0.2
  Downloading decorator-4.0.2-py2.py3-none-any.whl
Installing collected packages: decorator
  Found existing installation: decorator 4.0.1
    Uninstalling decorator-4.0.1:
      Successfully uninstalled decorator-4.0.1
Successfully installed decorator-4.0.2
You are using pip version 8.0.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

$ python -c "import plotly"
Traceback (most recent call last):
  [...]
  File "/Users/chriddyp/tmp/bp/test/venv/lib/python2.7/site-packages/plotly/graph_reference.py", line 232, in <module>
    @utils.memoize()
  File "/Users/chriddyp/tmp/bp/test/venv/lib/python2.7/site-packages/plotly/utils.py", line 492, in memoize
    return decorator(_memoize)
  File "/Users/chriddyp/tmp/bp/test/venv/lib/python2.7/site-packages/decorator.py", line 249, in decorator
    fun = getfullargspec(callerfunc).args[0]  # first arg
IndexError: list index out of range

$ pip install decorator==4.0.3
Collecting decorator==4.0.3
  Downloading decorator-4.0.3-py2.py3-none-any.whl
Installing collected packages: decorator
  Found existing installation: decorator 4.0.2
    Uninstalling decorator-4.0.2:
      Successfully uninstalled decorator-4.0.2
Successfully installed decorator-4.0.3
You are using pip version 8.0.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

$ python -c "import plotly"
Traceback (most recent call last):
  [...]
  File "/Users/chriddyp/tmp/bp/test/venv/lib/python2.7/site-packages/plotly/graph_reference.py", line 232, in <module>
    @utils.memoize()
  File "/Users/chriddyp/tmp/bp/test/venv/lib/python2.7/site-packages/plotly/utils.py", line 492, in memoize
    return decorator(_memoize)
  File "/Users/chriddyp/tmp/bp/test/venv/lib/python2.7/site-packages/decorator.py", line 249, in decorator
    fun = getfullargspec(callerfunc).args[0]  # first arg
IndexError: list index out of range

$ pip install decorator==4.0.4
Collecting decorator==4.0.4
  Using cached decorator-4.0.4-py2.py3-none-any.whl
Installing collected packages: decorator
  Found existing installation: decorator 4.0.3
    Uninstalling decorator-4.0.3:
      Successfully uninstalled decorator-4.0.3
Successfully installed decorator-4.0.4
You are using pip version 8.0.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

$ python -c "import plotly"
Traceback (most recent call last):
  [...]
  File "/Users/chriddyp/tmp/bp/test/venv/lib/python2.7/site-packages/plotly/graph_reference.py", line 232, in <module>
    @utils.memoize()
  File "/Users/chriddyp/tmp/bp/test/venv/lib/python2.7/site-packages/plotly/utils.py", line 492, in memoize
    return decorator(_memoize)
  File "/Users/chriddyp/tmp/bp/test/venv/lib/python2.7/site-packages/decorator.py", line 258, in decorator
    fun = getfullargspec(callerfunc).args[0]  # first arg
IndexError: list index out of range

$ pip install decorator==4.0.5
Collecting decorator==4.0.5
  Could not find a version that satisfies the requirement decorator==4.0.5 (from versions: 3.3.1, 3.3.2, 3.3.3, 3.4.0, 3.4.2, 4.0.0, 4.0.1, 4.0.2, 4.0.3, 4.0.4, 4.0.6, 4.0.8, 4.0.9, 4.0.10, 4.0.11)
No matching distribution found for decorator==4.0.5
You are using pip version 8.0.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

$ python -c "import plotly"
Traceback (most recent call last):
  [...]
  File "/Users/chriddyp/tmp/bp/test/venv/lib/python2.7/site-packages/plotly/graph_reference.py", line 232, in <module>
    @utils.memoize()
  File "/Users/chriddyp/tmp/bp/test/venv/lib/python2.7/site-packages/plotly/utils.py", line 492, in memoize
    return decorator(_memoize)
  File "/Users/chriddyp/tmp/bp/test/venv/lib/python2.7/site-packages/decorator.py", line 258, in decorator
    fun = getfullargspec(callerfunc).args[0]  # first arg
IndexError: list index out of range

$ pip install decorator==4.0.6
Collecting decorator==4.0.6
  Downloading decorator-4.0.6-py2.py3-none-any.whl
Installing collected packages: decorator
  Found existing installation: decorator 4.0.4
    Uninstalling decorator-4.0.4:
      Successfully uninstalled decorator-4.0.4
Successfully installed decorator-4.0.6
You are using pip version 8.0.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

$ python -c "import plotly"

@chriddyp
Copy link
Member

@ryecao @Kkevsterrr @miken - disregard the earlier requests, I have successfully reproduced the issue. Sorry for the noise!

I pushed a fix here: #762, should be available in version 2.0.9 of the library. You can also just upgrade decorator with pip install decorator --upgrade

@miken
Copy link
Author

miken commented May 30, 2017

@chriddyp Thank you. I was gonna respond but I'm using a different computer at work. This computer uses decorator==4.0.11 hence I didn't run into the issue with plotly 2.0.5. Looks like we're all set then.

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

5 participants