sephii / taxi

Taxi is a CLI to time tracking backends
https://taxi-timesheets.readthedocs.io/
Do What The F*ck You Want To Public License
41 stars 15 forks source link

AttributeError after upgrading to >=4.0: object has no attribute 'python_2_unicode_compatible' #96

Closed metaodi closed 8 years ago

metaodi commented 8 years ago

After my update to Taxi >= 4.0 using sudo -H pip install taxi-zebra, I get the following error message when calling taxi on the command line:

odi@fezzik:~> taxi
Traceback (most recent call last):
  File "/usr/local/bin/taxi", line 9, in <module>
    load_entry_point('taxi==4.0.2', 'console_scripts', 'taxi')()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 558, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2682, in load_entry_point
    return ep.load()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2355, in load
    return self.resolve()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2361, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/local/lib/python2.7/dist-packages/taxi/commands/__init__.py", line 1, in <module>
    from . import (  # NOQA
  File "/usr/local/lib/python2.7/dist-packages/taxi/commands/base.py", line 12, in <module>
    from ..backends.registry import backends_registry
  File "/usr/local/lib/python2.7/dist-packages/taxi/backends/__init__.py", line 69, in <module>
    @six.python_2_unicode_compatible
AttributeError: 'module' object has no attribute 'python_2_unicode_compatible'

For me it looks like an error with six. I tried upgrading from six 1.9 to six 1.10, but the error is the same.

Any help would be appreciated.

metaodi commented 8 years ago

Btw: I removed the decorators and it still seems to work.

sephii commented 8 years ago

Hi @metaodi, this issue seems to be related to Xcode, although I haven't been able to fully dig it up since I'm not familiar with OS X. The fix is documented in the wiki: https://github.com/sephii/taxi/wiki/Problems-when-installing-taxi#attributeerror-module-object-has-no-attribute-python_2_unicode_compatible

metaodi commented 8 years ago

I run into this problem on my Ubuntu (14.10) machine. I used the standard python installation (which currently uses Python 2.7.6) and I tried a ppa to install Python 2.7.10, but still the same error.

sephii commented 8 years ago

Oh, that's weird.

Could you run & paste the result of the following?

pip freeze pip show six pip show taxi

metaodi commented 8 years ago

Sure,

odi@fezzik:~> pip freeze
adium-theme-ubuntu==0.3.4
alembic==0.7.4
apt-xapian-index==0.45
arista==0.9.7
BeautifulSoup==3.2.1
beautifulsoup4==4.3.2
boto==2.8.0
bzr==2.7.0.dev1
chardet==2.0.1
ckanapi==3.4
ckanclient==0.10
click==5.1
colorama==0.3.3
command-not-found==0.3
configglue==1.1.2
configobj==4.7.2
coverage==3.7.1
coveralls==0.4.1
cssselect==0.9.1
debtagshw==0.1
defer==1.0.6
deluge==1.3.6
dirspec==13.10
dnspython==1.11.1
docopt==0.6.1
docutils==0.12
dumptruck==0.1.6
duplicity==0.6.23
errorhandler==1.1.1
Fabric==1.10.2
fahrplan==0.1b7
filechunkio==1.5
flake8==2.4.1
Flask==0.10.1
geojson==1.0.9
git-review==1.23
gitric==0.3
GnuPGInterface==0.3.2
hamster-indicator==0.0.0
howdoi==1.1.6
httmock==1.0.7
httpie==0.8.0
httplib2==0.8
hypothesis==1.6.2
hypothesis-datetime==1.6.1
ipython==2.1.0
itsdangerous==0.24
Jinja2==2.7.3
keyring==3.5
launchpadlib==1.10.2
lazr.restfulclient==0.13.3
lazr.uri==1.0.3
lockfile==0.8
lxml==2.2.4
Mako==0.9.1
Markdown==2.4.1
MarkupSafe==0.18
mccabe==0.3
mechanize==0.2.5
mercurial==2.8.2
mock==1.0.1
mwparserfromhell==0.3.3
netifaces==0.8
nose==1.3.1
numpy==1.8.2
oauth==1.0.1
oauthlib==1.0.3
oneconf==0.3.7.14.4.1
osmapi==0.3.0
overpass==0.1.0
OWSLib==0.7.1
PAM==0.4.2
paramiko==1.10.1
pathlib==1.0.1
pdfminer==20140328
pdoc==0.3.1
pep8==1.5.7
pexpect==3.1
Pillow==2.3.0
piston-mini-client==0.7.5
protobuf==2.5.0
psutil==3.1.1
py==1.4.20
pyaml==13.12.0
pycrypto==2.6.1
pycups==1.9.66
pycurl==7.19.3
pyflakes==0.8.1
pygame===1.9.1release
Pygments==1.6
pygobject==3.12.0
pygpgme==0.3
pyinotify==0.9.4
pymongo==2.6.3
pyoai==2.4.4
pyOpenSSL==0.14
pypandoc==0.7.0
pyquery==1.2.8
pyserial==2.6
pysmbc==1.0.14.1
pystache==0.5.4
pytest==2.5.2
python-apt===0.9.3.5ubuntu1
python-dateutil==1.5
python-debian===0.1.21-nmu2ubuntu2
python-distutils-extra==2.38
python-gflags==2.0
python-Levenshtein==0.10.2
python-libtorrent==0.16.13
python-modargs==1.2
python-stdnum==0.7
pytz===2012j
pywikibot==2.0b1
Pywikipediabot==2.0b1
pyxdg==0.25
PyYAML==3.11
queuelib==1.2.2
quickly-lens-templates==0.0.3
reportlab==3.0
requests==2.7.0
requests-cache==0.4.4
requests-oauthlib==0.5.0
rhythmbox-ubuntuone==13.10
schema==0.2.0
scraperwiki==0.4.1
Scrapy==0.24.4
SecretStorage==2.0.0
sessioninstaller==0.0.0
simplejson==2.2.1
six==1.10.0
software-center-aptd-plugins==0.0.0
Sphinx==1.2.3
SQLAlchemy==0.9.8
ssh-import-id==3.21
system-service==0.1.6
taxi==4.0.2
taxi-zebra==1.0.4
thefuck==2.6
tox==1.7.1
turbotlib==0.0.6
tweepy==3.4.0
Twisted==15.0.0
Twisted-Core==13.2.0
Twisted-Names==13.2.0
Twisted-Web==13.2.0
tzlocal==1.2
ubuntuone-storage-protocol==13.10
Unidecode==0.4.9
unittest2==0.5.1
unity-lens-photos==1.0
unity-scope-sshsearch==0.1
unity-singlet==0.2.2
urllib3==1.7.1
vboxapi==1.0
virtualenv==1.11.4
w3lib==1.11.0
wadllib==1.3.2
Werkzeug==0.10.4
wheel==0.24.0
winpdb==1.4.8
wxPython==2.8.12.1
wxPython-common==2.8.12.1
xdiagnose===3.6.3build2
xlrd==0.9.2
xmltodict==0.9.0
zope.interface==4.1.2
odi@fezzik:~> pip show six
---
Metadata-Version: 2.0
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: benjamin@python.org
License: MIT
Location: /usr/local/lib/python2.7/dist-packages
Requires:
odi@fezzik:~> pip show taxi
---
Metadata-Version: 1.1
Name: taxi
Version: 4.0.2
Summary: Taxi: timesheeting made easy
Home-page: https://github.com/sephii/taxi
Author: Sylvain Fankhauser
Author-email: sylvain.fankhauser@liip.ch
License: wtfpl
Location: /usr/local/lib/python2.7/dist-packages
Requires: click, six
Entry-points:
  [console_scripts]
  taxi = taxi.commands.base:cli
  [taxi.backends]
  dummy = taxi.backends.dummy:DummyBackend
sephii commented 8 years ago

Could you check if /usr/local/lib/python2.7/dist-packages/six.py contains a python_2_unicode_compatible function (like in here https://bitbucket.org/gutworth/six/src/e5218c3f66a2614acb7572204a27e2b508682168/six.py?at=1.10.0&fileviewer=file-view-default#six.py-828)?

metaodi commented 8 years ago

Yes it does:

odi@fezzik:~> grep "python_2_unicode_compatible" /usr/local/lib/python2.7/dist-packages/six.py
def python_2_unicode_compatible(klass):
...
sephii commented 8 years ago

Wow now that's even weirder. Can you please run which taxi and cat $(which taxi)?

metaodi commented 8 years ago
odi@fezzik:~> which taxi
/usr/local/bin/taxi
odi@fezzik:~> cat $(which taxi)
#!/usr/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'taxi==4.0.2','console_scripts','taxi'
__requires__ = 'taxi==4.0.2'
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.exit(
        load_entry_point('taxi==4.0.2', 'console_scripts', 'taxi')()
    )
sephii commented 8 years ago

Wow wow... let's try something else: fire up a Python REPL by typing /usr/bin/python, and run from six import python_2_unicode_compatible and tell me if it fails. Also please paste the output of:

import sys
sys.path
metaodi commented 8 years ago

This finally brought me on the right track!

Appearently I had two versions of six installed, one in /usr/lib/python2.7/dist-packages/ and the other in /usr/lib/local/python2.7/dist-packages/. The former was loaded first and did not contain python_2_unicode_compatible, the latter was fine.

I removed the old version and now everything works as expected. I don't really know what's the difference between those two locations. The only thing I found was an old StackOverflow question. So maybe six was installed as part of some package I installed using apt.

Anyway, this issue is fixed for me. Thanks @sephii for your remote debugging :wink:

sephii commented 8 years ago

Cool! Just like you said, the version of six in /usr/lib/python2.7 was probably the distribution package (like python-six), and /usr/lib/local/python2.7 a version installed by pip, and the former took precedence over the latter... anyway, glad you finally got it to work!