Questions tagged [six-python]

Six is a Python 2 and 3 compatibility library. It provides utility functions for smoothing over the differences between the Python versions with the goal of writing Python code that is compatible on both Python versions.

13 questions
62
votes
2 answers

Python Metaclass : Understanding the 'with_metaclass()'

I want to ask what the with_metaclass() call means in the definition of a class. E.g.: class Foo(with_metaclass(Cls1, Cls2)): Is it a special case where a class inherits from a metaclass? Is the new class a metaclass, too?
Zakos
  • 2,448
  • 4
  • 16
  • 20
18
votes
1 answer

How can I call super() so it's compatible in 2 and 3?

I'm trying to write 2/3 compatible code using six, but I don't see how I can call super() in a cross-compatible manner. Is there some better way besides, for example: class MyClass(MyBase): def __init__(): if six.PY3: …
Nick T
  • 25,754
  • 12
  • 83
  • 121
13
votes
1 answer

unicode_literals and type()

I'm having problems supporting python2 and python3 on a type() call. This demonstrates the problem: from __future__ import unicode_literals name='FooClass' type(name, (dict,), {}) No problem on python3, but on python2: Traceback (most recent call…
jpic
  • 32,891
  • 5
  • 112
  • 113
12
votes
3 answers

Can't find "six", but it's installed

I have six installed (even reinstalled it). $ pip show six --- Name: six Version: 1.7.3 Location: /usr/lib/python2.6/site-packages Requires: But when I try to run csvcut, it can't find it. $ csvcut -n monster.csv Traceback (most recent call…
mhwombat
  • 8,026
  • 28
  • 53
12
votes
7 answers

Python Error: "ImportError: No module named six"

I am running Python 2.7 on a Windows 7 OS Here is what I run: >>> import matplotlib.pyplot as plt Then I get this: Traceback (most recent call last): File "", line 1, in import matplotlib.pyplot as plt File…
statsNoob
  • 1,325
  • 5
  • 18
  • 36
11
votes
3 answers

No module named six

After installing transifex and ./manage.py the following error shows up: Error: No modules named six. Python Six is installed in the virtualenv (from https://pypi.python.org/pypi/six) Django Version is 1.4 Any help would be great! thx & best…
Michael Brueckler
  • 123
  • 1
  • 1
  • 4
8
votes
0 answers

How do I use six?

I was using python-future for a while until profiling revealed that my program's 50 million instantiations of newint was increasing the runtime of my program 10-fold. I have the thing running fine in Python 3, but trying to make it compatible with…
Nick T
  • 25,754
  • 12
  • 83
  • 121
5
votes
1 answer

Reraising an exception in Cython on Python 2 and Python3

I have some Cython code that currently looks exc = sys.exc_info() raise exc[0], exc[1], exc[2] This doesn't work on Python3, since the "raise from tuple" form is no longer allowed. Were this normal Python code, I would just use six.reraise, but…
Alex Gaynor
  • 14,353
  • 9
  • 63
  • 113
3
votes
2 answers

Cannot import name six Django-CMS

Am Using django 1.3 and django-cms 2.2 and when i run i get an error as follows: django.template.base.TemplateSyntaxError: 'cms_tags' is not a valid tag library: ImportError raised loading cms.templatetags.cms_tags: cannot import name six
user2842009
2
votes
1 answer

transifex Error cannot import name six

I download and install the transifex with several steps but I always get Error cannot import name six: apt-get install python-dev apt-get install gcc make install python python-setuptools python-imaging easy_install transifex easy_install…
mcolak
  • 609
  • 1
  • 7
  • 13
1
vote
2 answers

Django and the Python six compatibility module

Recently I was working on my Django web app, when I discovered that for some reason Django only worked when I used a python 2.x. Interpreter, but all the while I had thought it had been configured for Python 3 and thus was coding like so. So I…
Anthony
  • 670
  • 6
  • 20
1
vote
2 answers

py2exe cannot import from six.py

I'm trying use py2exe on a program that imports urlparse from six.moves.urllib_parse. Here is the program: # hello.py from six.moves.urllib_parse import urlparse print('hello world') And here is my setup.py: from distutils.core import setup import…
priomsrb
  • 2,602
  • 3
  • 26
  • 34
0
votes
2 answers

control stdin and stdout of a ruby program in python

First I should notice: I'm a python programmer with no knowledge about ruby! Now, I need to feed stdin of a ruby program and capture stdout of the script with a python program. I tried this (forth solution) and the code works in python2.7 but not in…
ARF
  • 72
  • 7