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

AttributeError: 'module' object has no attribute 'python_2_unicode_compatible' #747

Closed
gka opened this issue Jan 9, 2017 · 13 comments
Closed

Comments

@gka
Copy link

gka commented Jan 9, 2017

$ head my-valid-data.csv | csvlook

output

Traceback (most recent call last):
  File "/usr/local/bin/csvlook", line 7, in <module>
    from csvkit.utilities.csvlook import launch_new_instance
  File "/usr/local/lib/python2.7/site-packages/csvkit/__init__.py", line 15, in <module>
    import agate
  File "/usr/local/lib/python2.7/site-packages/agate/__init__.py", line 5, in <module>
    from agate.aggregations import *
  File "/usr/local/lib/python2.7/site-packages/agate/aggregations/__init__.py", line 18, in <module>
    from agate.aggregations.base import Aggregation  # noqa
  File "/usr/local/lib/python2.7/site-packages/agate/aggregations/base.py", line 8, in <module>
    @six.python_2_unicode_compatible
AttributeError: 'module' object has no attribute 'python_2_unicode_compatible'
@jpmckinney
Copy link
Member

I can't reproduce on Python 2. Please provide a sample file.

@jpmckinney
Copy link
Member

Ah, agate only requires an old version of six. To use csvkit before the next release, run pip install --upgrade six.

@johnhawkinson
Copy link

Upgrading six does not fix this for me

bash-3.2# pip install -U six
Requirement already up-to-date: six in /Library/Python/2.7/site-packages
bash-3.2# pip show six
Name: six
Version: 1.10.0
Summary: Python 2 and 3 compatibility utilities
Home-page: http://pypi.python.org/pypi/six/
Author: Benjamin Peterson
Author-email: [email protected]
License: MIT
Location: /Library/Python/2.7/site-packages
Requires: 
bash-3.2# csvsql
Traceback (most recent call last):
  File "/usr/local/bin/csvsql", line 11, in <module>
    load_entry_point('csvkit==1.0.1', 'console_scripts', 'csvsql')()
  File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 561, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 2631, in load_entry_point
    return ep.load()
  File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 2291, in load
    return self.resolve()
  File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 2297, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/Library/Python/2.7/site-packages/csvkit/__init__.py", line 15, in <module>
    import agate
  File "/Library/Python/2.7/site-packages/agate/__init__.py", line 5, in <module>
    from agate.aggregations import *
  File "/Library/Python/2.7/site-packages/agate/aggregations/__init__.py", line 18, in <module>
    from agate.aggregations.base import Aggregation  # noqa
  File "/Library/Python/2.7/site-packages/agate/aggregations/base.py", line 8, in <module>
    @six.python_2_unicode_compatible
AttributeError: 'module' object has no attribute 'python_2_unicode_compatible'
bash-3.2# pip install -U csvkit
Requirement already up-to-date: csvkit in /Library/Python/2.7/site-packages
Requirement already up-to-date: agate>=1.5.5 in /Library/Python/2.7/site-packages (from csvkit)
Requirement already up-to-date: agate-excel>=0.2.0 in /Library/Python/2.7/site-packages (from csvkit)
Requirement already up-to-date: agate-dbf>=0.2.0 in /Library/Python/2.7/site-packages (from csvkit)
Requirement already up-to-date: agate-sql>=0.5.0 in /Library/Python/2.7/site-packages (from csvkit)
Requirement already up-to-date: six>=1.6.1 in /Library/Python/2.7/site-packages (from csvkit)
Requirement already up-to-date: isodate>=0.5.4 in /Library/Python/2.7/site-packages (from agate>=1.5.5->csvkit)
Requirement already up-to-date: awesome-slugify>=1.6.5 in /Library/Python/2.7/site-packages (from agate>=1.5.5->csvkit)
Requirement already up-to-date: parsedatetime>=2.1 in /Library/Python/2.7/site-packages (from agate>=1.5.5->csvkit)
Requirement already up-to-date: Babel>=2.0 in /Library/Python/2.7/site-packages (from agate>=1.5.5->csvkit)
Requirement already up-to-date: leather>=0.3.2 in /Library/Python/2.7/site-packages (from agate>=1.5.5->csvkit)
Requirement already up-to-date: pytimeparse>=1.1.5 in /Library/Python/2.7/site-packages (from agate>=1.5.5->csvkit)
Requirement already up-to-date: openpyxl>=2.3.0 in /Library/Python/2.7/site-packages (from agate-excel>=0.2.0->csvkit)
Requirement already up-to-date: xlrd>=0.9.4 in /Library/Python/2.7/site-packages (from agate-excel>=0.2.0->csvkit)
Requirement already up-to-date: dbfread>=2.0.5 in /Library/Python/2.7/site-packages (from agate-dbf>=0.2.0->csvkit)
Requirement already up-to-date: sqlalchemy>=1.0.8 in /Library/Python/2.7/site-packages (from agate-sql>=0.5.0->csvkit)
Requirement already up-to-date: regex in /Library/Python/2.7/site-packages (from awesome-slugify>=1.6.5->agate>=1.5.5->csvkit)
Requirement already up-to-date: Unidecode<0.05,>=0.04.14 in /Library/Python/2.7/site-packages (from awesome-slugify>=1.6.5->agate>=1.5.5->csvkit)
Requirement already up-to-date: future in /Library/Python/2.7/site-packages (from parsedatetime>=2.1->agate>=1.5.5->csvkit)
Requirement already up-to-date: pytz>=0a in /Library/Python/2.7/site-packages (from Babel>=2.0->agate>=1.5.5->csvkit)
Requirement already up-to-date: jdcal in /Library/Python/2.7/site-packages (from openpyxl>=2.3.0->agate-excel>=0.2.0->csvkit)
Requirement already up-to-date: et_xmlfile in /Library/Python/2.7/site-packages (from openpyxl>=2.3.0->agate-excel>=0.2.0->csvkit)
bash-3.2# 

Any suggestions? OS X 10.10.5.

@jpmckinney
Copy link
Member

Hmm, I don't know if it makes any difference, but I'm on OS X 10.12.3 and I always run Python in a virtualenv.

@senrabc
Copy link

senrabc commented Apr 29, 2017

Having the same issue on 10.10.5 with six at 1.10.0
$ pip show six
Name: six
Version: 1.10.0
Summary: Python 2 and 3 compatibility utilities
Home-page: http://pypi.python.org/pypi/six/
Author: Benjamin Peterson
Author-email: [email protected]
License: MIT
Location: /Library/Python/2.7/site-packages
Requires:

$ csvsql
Traceback (most recent call last):
File "/usr/local/bin/csvsql", line 7, in
from csvkit.utilities.csvsql import launch_new_instance
File "/Library/Python/2.7/site-packages/csvkit/init.py", line 15, in
import agate
File "/Library/Python/2.7/site-packages/agate/init.py", line 5, in
from agate.aggregations import *
File "/Library/Python/2.7/site-packages/agate/aggregations/init.py", line 18, in
from agate.aggregations.base import Aggregation # noqa
File "/Library/Python/2.7/site-packages/agate/aggregations/base.py", line 8, in
@six.python_2_unicode_compatible
AttributeError: 'module' object has no attribute 'python_2_unicode_compatible'

@jpmckinney
Copy link
Member

@senrabc Run pip show csvkit ?

@senrabc
Copy link

senrabc commented Apr 30, 2017

$ pip show csvkit
Name: csvkit
Version: 1.0.2
Summary: A suite of command-line tools for working with CSV, the king of tabular file formats.
Home-page: http://csvkit.rtfd.org/
Author: Christopher Groskopf
Author-email: [email protected]
License: MIT
Location: /Library/Python/2.7/site-packages
Requires: agate-excel, six, agate, agate-sql, agate-dbf

@jpmckinney
Copy link
Member

Hmm. What's python --version?

@senrabc
Copy link

senrabc commented Apr 30, 2017

$ python --version
Python 2.7.10

@jpmckinney
Copy link
Member

What's your OS? The only possibility is that Python (when running a csvkit command) is pickup up another version of six installed somewhere else on your system. Are you running this inside a virtual environment? That should also fix it.

@senrabc
Copy link

senrabc commented May 4, 2017

OSX 10.10.5

@jpmckinney
Copy link
Member

I recommend trying from within a virtual environment (using virtualenv or pyenv) to see if that resolves the issue.

@c6stephens
Copy link

For anyone else who runs into this error on macOS, note that the system installed Python interpreter comes with an old version of six:

>>> import six
# /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.pyc matches /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.py
import six # precompiled from /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.pyc

You can upgrade Python using Homebrew, override the default search path, or live on the edge and delete these files. I upgraded Python via Homebew.

More info here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants