Repository: plotly/plotly.py

Issue:
Installing simplejson kills pip on anaconda
@theengineear, from: http://stackoverflow.com/questions/28751216/plotly-killed-my-python-install?nah=1#28754036

Python 3.4 on Windows via Anaconda 2.1.0: installing simplejson (which is pulled in by Plotly's requirements.txt) kills pip:

```
Traceback (most recent call last):
  File "C:\Anaconda3\Scripts\pip-script.py", line 3, in <module>
    from pip import main
  File "C:\Anaconda3\lib\site-packages\pip\__init__.py", line 11, in <module>
    from pip.vcs import git, mercurial, subversion, bazaar  # noqa
  File "C:\Anaconda3\lib\site-packages\pip\vcs\mercurial.py", line 9, in <module>
    from pip.download import path_to_url
  File "C:\Anaconda3\lib\site-packages\pip\download.py", line 22, in <module>
    from pip._vendor import requests, six
  File "C:\Anaconda3\lib\site-packages\pip\_vendor\requests\__init__.py", line 58, in <module>
    from . import utils
  File "C:\Anaconda3\lib\site-packages\pip\_vendor\requests\utils.py", line 25, in <module>
    from .compat import parse_http_list as _parse_list_header
  File "C:\Anaconda3\lib\site-packages\pip\_vendor\requests\compat.py", line 77, in <module>
    import simplejson as json
  File "C:\Anaconda3\lib\site-packages\simplejson\__init__.py", line 112, in <module>
    from .scanner import JSONDecodeError
  File "C:\Anaconda3\lib\site-packages\simplejson\scanner.py", line 10, in <module>
    c_make_scanner = _import_c_make_scanner()
  File "C:\Anaconda3\lib\site-packages\simplejson\scanner.py", line 6, in _import_c_make_scanner
    from simplejson._speedups import make_scanner
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x83 in position 4: invalid start byte
```

Can we _not_ install simplejson unless it's really needed (Python 2.6 systems)?  Or is there another way we can work around this Anaconda issue?  (Logged for Anaconda as: https://github.com/ContinuumIO/anaconda-issues/issues/238 )



Discussion:
Ah, bummer. Yeah, we wanted to unify the install process. Do you know of a way to have pip optionally install something depending on the python version?

@scjody , I think a good non-hacky workaround is to allow installing like this:

pip install plolty[PY2.6]

http://pythonhosted.org/setuptools/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies

Then, we can just check and shoot out a warning explaining that.


Resolving patch:
diff --git a/plotly/graph_objs/graph_objs_tools.py b/plotly/graph_objs/graph_objs_tools.py
--- a/plotly/graph_objs/graph_objs_tools.py
+++ b/plotly/graph_objs/graph_objs_tools.py
@@ -4,8 +4,16 @@
 import os
 import sys
 if sys.version[:3] == '2.6':
-    from ordereddict import OrderedDict
-    import simplejson as json
+    try:
+        from ordereddict import OrderedDict
+        import simplejson as json
+    except ImportError:
+        raise ImportError(
+            "Looks like you're running Python 2.6. Plotly expects newer "
+            "standard library versions of ordereddict and json. You can "
+            "simply upgrade with these 'extras' with the following terminal "
+            "command:\npip install 'plotly[PY2.6]'"
+        )
 else:
     from collections import OrderedDict
     import json
diff --git a/plotly/version.py b/plotly/version.py
--- a/plotly/version.py
+++ b/plotly/version.py
@@ -1 +1 @@
-__version__ = '1.6.9'
+__version__ = '1.6.10'
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -41,9 +41,6 @@ def readme():
                 'plotly/matplotlylib/mplexporter',
                 'plotly/matplotlylib/mplexporter/renderers'],
       package_data={'plotly': ['graph_reference/*.json', 'widgets/*.js']},
-      install_requires=['requests',
-                        'six',
-                        'pytz',
-                        'ordereddict',
-                        'simplejson'],
+      install_requires=['requests', 'six', 'pytz'],
+      extras_require={"PY2.6": ['simplejson', 'ordereddict']},
       zip_safe=False)


Test patch: