io/common.py: boto3 with python 3.5 · Issue #11915 · pandas-dev/pandas (original) (raw)

Pandas v0.17.1 won't import for Python 3.5 due to boto. Replacing with boto3 appears to fix the issue. I'd like to suggest replacing dependencies on boto with boto3 for at least Python 3.5. I didn't test with other Python 3x versions. Thank you

Update (2016-01-10T02:45:00Z): There are significant API changes between boto and boto3 (http://boto3.readthedocs.org/en/latest/guide/migrations3.html). Doing import boto3 as boto as below will allow pandas to import for Python 3.5, but then AWS functionality is broken.

samuel_harrold@instance-20151227t225000z:~$ ipython
Python 3.5.1 |Anaconda 2.4.1 (64-bit)| (default, Dec  7 2015, 11:16:01) 
Type "copyright", "credits" or "license" for more information.

IPython 4.0.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import pandas
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-1-d6ac987968b6> in <module>()
----> 1 import pandas

/home/samuel_harrold/anaconda3/lib/python3.5/site-packages/pandas/__init__.py in <module>()
     40 
     41 # let init-time option registration happen
---> 42 import pandas.core.config_init
     43 
     44 from pandas.core.api import *

/home/samuel_harrold/anaconda3/lib/python3.5/site-packages/pandas/core/config_init.py in <module>()
     15                                 is_instance_factory, is_one_of_factory,
     16                                 get_default_val)
---> 17 from pandas.core.format import detect_console_encoding
     18 
     19 

/home/samuel_harrold/anaconda3/lib/python3.5/site-packages/pandas/core/format.py in <module>()
      8 from pandas.core.base import PandasObject
      9 from pandas.core.common import adjoin, notnull
---> 10 from pandas.core.index import Index, MultiIndex, _ensure_index
     11 from pandas import compat
     12 from pandas.compat import(StringIO, lzip, range, map, zip, reduce, u,

/home/samuel_harrold/anaconda3/lib/python3.5/site-packages/pandas/core/index.py in <module>()
     29 from pandas.core.strings import StringAccessorMixin
     30 from pandas.core.config import get_option
---> 31 from pandas.io.common import PerformanceWarning
     32 
     33 

/home/samuel_harrold/anaconda3/lib/python3.5/site-packages/pandas/io/common.py in <module>()
     66 
     67 try:
---> 68     from boto.s3 import key
     69     class BotoFileLikeReader(key.Key):
     70         """boto Key modified to be more file-like

/home/samuel_harrold/anaconda3/lib/python3.5/site-packages/boto/__init__.py in <module>()
   1214     return storage_uri(uri_str)
   1215 
-> 1216 boto.plugin.load_plugins(config)

/home/samuel_harrold/anaconda3/lib/python3.5/site-packages/boto/plugin.py in load_plugins(config)
     90         return
     91     directory = config.get('Plugin', 'plugin_directory')
---> 92     for file in glob.glob(os.path.join(directory, '*.py')):
     93         _import_module(file)

/home/samuel_harrold/anaconda3/lib/python3.5/posixpath.py in join(a, *p)
     87                 path += sep + b
     88     except (TypeError, AttributeError, BytesWarning):
---> 89         genericpath._check_arg_types('join', a, *p)
     90         raise
     91     return path

/home/samuel_harrold/anaconda3/lib/python3.5/genericpath.py in _check_arg_types(funcname, *args)
    141         else:
    142             raise TypeError('%s() argument must be str or bytes, not %r' %
--> 143                             (funcname, s.__class__.__name__)) from None
    144     if hasstr and hasbytes:
    145         raise TypeError("Can't mix strings and bytes in path components") from None

TypeError: join() argument must be str or bytes, not 'NoneType'

In [2]: exit()
samuel_harrold@instance-20151227t225000z:~$ cp /home/samuel_harrold/anaconda3/lib/python3.5/site-packages/pandas/io/common_boto3.py /home/samuel_harrold/anaconda3/lib/python3.5/site-packages/pandas/io/common.py
samuel_harrold@instance-20151227t225000z:~$ diff /home/samuel_harrold/anaconda3/lib/python3.5/site-packages/pandas/io/common.py /home/samuel_harrold/anaconda3/lib/python3.5/site-packages/pandas/io/common_orig.py
68c68
<     from boto3.s3 import key

---
>     from boto.s3 import key
272c272
<             import boto3 as boto

---
>             import boto
samuel_harrold@instance-20151227t225000z:~$ ipython
Python 3.5.1 |Anaconda 2.4.1 (64-bit)| (default, Dec  7 2015, 11:16:01) 
Type "copyright", "credits" or "license" for more information.

IPython 4.0.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import pandas

In [2]: # success

In [3]: exit()
samuel_harrold@instance-20151227t225000z:~$ ipython
Python 3.5.1 |Anaconda 2.4.1 (64-bit)| (default, Dec  7 2015, 11:16:01) 
Type "copyright", "credits" or "license" for more information.

IPython 4.0.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import pandas as pd

In [2]: pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 3.5.1.final.0
python-bits: 64
OS: Linux
OS-release: 3.16.0-0.bpo.4-amd64
machine: x86_64
processor: 
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.17.1
nose: 1.3.7
pip: 7.1.2
setuptools: 19.1.1
Cython: 0.23.4
numpy: 1.10.2
scipy: 0.16.0
statsmodels: 0.6.1
IPython: 4.0.1
sphinx: 1.3.1
patsy: 0.4.0
dateutil: 2.4.2
pytz: 2015.7
blosc: None
bottleneck: 1.0.0
tables: 3.2.2
numexpr: 2.4.4
matplotlib: 1.5.0
openpyxl: 2.2.6
xlrd: 0.9.4
xlwt: 1.0.0
xlsxwriter: 0.7.7
lxml: 3.4.4
bs4: 4.4.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.9
pymysql: None
psycopg2: None
Jinja2: None

In [3]: