0

I am currently trying to run some test on a program, but suddenly I keep getting the same error, no matter what I run it on, be it the program I want to test, a basic tutorial file, an empty file or nothing. The error is :

  File "/usr/local/bin/py.test", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/_pytest/config.py", line 38, in main
    config = _prepareconfig(args, plugins)
  File "/usr/local/lib/python2.7/dist-packages/_pytest/config.py", line 117, in _prepareconfig
    pluginmanager=pluginmanager, args=args)
  File "/usr/local/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 724, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/usr/local/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 338, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/usr/local/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 333, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File "/usr/local/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 595, in execute
    return _wrapped_call(hook_impl.function(*args), self.execute)
  File "/usr/local/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 249, in _wrapped_call
    wrap_controller.send(call_outcome)
  File "/usr/local/lib/python2.7/dist-packages/_pytest/helpconfig.py", line 28, in pytest_cmdline_parse
    config = outcome.get_result()
  File "/usr/local/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 279, in get_result
    _reraise(*ex)  # noqa
  File "/usr/local/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 264, in __init__
    self.result = func()
  File "/usr/local/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 596, in execute
    res = hook_impl.function(*args)
  File "/usr/local/lib/python2.7/dist-packages/_pytest/config.py", line 852, in pytest_cmdline_parse
    self.parse(args)
  File "/usr/local/lib/python2.7/dist-packages/_pytest/config.py", line 957, in parse
    self._preparse(args)
  File "/usr/local/lib/python2.7/dist-packages/_pytest/config.py", line 918, in _preparse
    self.pluginmanager.load_setuptools_entrypoints("pytest11")
  File "/usr/local/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 501, in load_setuptools_entrypoints
    plugin = ep.load()
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2088, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/usr/local/lib/python2.7/dist-packages/pytest_bdd/__init__.py", line 3, in <module>
    from pytest_bdd.steps import given, when, then
  File "/usr/local/lib/python2.7/dist-packages/pytest_bdd/steps.py", line 43, in <module>
    from .feature import parse_line, force_encode
  File "/usr/local/lib/python2.7/dist-packages/pytest_bdd/feature.py", line 37, in <module>
    from . import exceptions
  File "/usr/local/lib/python2.7/dist-packages/pytest_bdd/exceptions.py", line 65, in <module>
    @six.python_2_unicode_compatible
AttributeError: 'module' object has no attribute 'python_2_unicode_compatible'

I could not find anything relating specifically to this bug in pytest, although it seems to occur in other programs using the six module. I tried reinstalling both six and pytest, but so far no luck. What is the problem and how to solve it?

Here is the result for print(six.__file__, dir(six)):

('/usr/lib/python2.7/dist-packages/six.pyc',
 ['BytesIO', 'Iterator', 'MAXSIZE', 'Module_six_moves_urllib',
  'Module_six_moves_urllib_error', 'Module_six_moves_urllib_parse',
  'Module_six_moves_urllib_request', 'Module_six_moves_urllib_response',
  'Module_six_moves_urllib_robotparser', 'MovedAttribute', 'MovedModule',
  'PY2', 'PY3', 'StringIO', '_LazyDescr', '_LazyModule', '_MovedItems',
  '__author__', '__builtins__', '__doc__', '__file__', '__name__',
  '__package__', '__version__', '_add_doc', '_func_closure', '_func_code',
  '_func_defaults', '_func_globals', '_import_module', '_iteritems',
  '_iterkeys', '_iterlists', '_itervalues', '_meth_func', '_meth_self',
  '_moved_attributes', '_urllib_error_moved_attributes',
  '_urllib_parse_moved_attributes', '_urllib_request_moved_attributes',
  '_urllib_response_moved_attributes', '_urllib_robotparser_moved_attributes',
  'add_metaclass', 'add_move', 'advance_iterator', 'b', 'binary_type',
  'byte2int', 'callable', 'class_types', 'create_bound_method', 'exec_',
  'get_function_closure', 'get_function_code', 'get_function_defaults',
  'get_function_globals', 'get_method_function', 'get_method_self',
  'get_unbound_function', 'indexbytes', 'int2byte', 'integer_types',
  'iterbytes', 'iteritems', 'iterkeys', 'iterlists', 'itervalues', 'moves',
  'next', 'operator', 'print_', 'remove_move', 'reraise', 'string_types',
  'sys', 'text_type', 'types', 'u', 'unichr', 'with_metaclass'])
3
  • Same idea, print the 'six' module version and follow reinstall instructions - stackoverflow.com/questions/29164045/… Commented Oct 7, 2015 at 9:05
  • Are you sure you're importing the correct six? What does print(six.__file__, dir(six)) (i.e. where is it and what's in it) show? Commented Oct 7, 2015 at 9:09
  • Added to the question Commented Oct 7, 2015 at 9:18

1 Answer 1

1

The lack of python_2_unicode_compatible and the presence of _iteritems, _itervalues, ... indicates that you are using an old version of Python Six.

Precisely, python_2_unicode_compatible was introduced in September 2014.

You can install a more recent version with pip and virtualenv.

Sign up to request clarification or add additional context in comments.

6 Comments

Updating Six (with sudo pip install --upgrade six) does not seem to work. Also py.test was working fine until a few days ago so I am not quite sure about a module introduced last year.
@Slereah: what version are you using? Try print(six.__version__)
Current version is 1.5.2
@Slereah: well, as you can see yourself, latest version is 1.10.0 (released today).
Doing a force-reinstall tells me indeed that the version installed is 1.10.0, but the version used in python is still 1.5.2
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.