Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: No Module named six; six already installed

Tags:

python

macos

six

I'm running python 3.6 on Mac OS X El Capitan.

I'm trying to run code that uses the six module, but am getting the following error:

ImportError: No module named six.

When I search for six it appears no problem, and I've made sure that the location is included in the sys.path

$ 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: /usr/anaconda/lib/python3.6/site-packages

However, when I try to run something basic I encounter an error:

$ python -c "import six; print (six.__version__)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: module 'six' has no attribute 'version'

I've tried uninstalling and reinstalling, and have tried installing using $ python -m pip install six, but nothing has worked.

If anyone has any ideas or needs more information, I would appreciate it.

like image 310
Lucas13 Avatar asked Jun 20 '17 16:06

Lucas13


2 Answers

This should work:

pip install --ignore-installed six

more info here: https://github.com/pypa/pip/issues/3165

like image 97
raam86 Avatar answered Oct 20 '22 20:10

raam86


I didn't see any method version() for six from six Documentation Release 1.10.0, and the error you got also says six doesn't have the attribute which makes sense to me, below I print all the attributes and there's __version__ inside

>>> import six
>>> six.__dir__()
['_moved_attributes', 'remove_move', '__path__', '__author__', '_MovedItems', 'Module_six_moves_urllib', 'Module_six_moves_urllib_robotparser', 'raise_from', '_SixMetaPathImporter', 'get_function_code', 'callable', 'absolute_import', '_func_code', 'moves', '_urllib_error_moved_attributes', 'text_type', 'Module_six_moves_urllib_parse', 'iteritems', 'iterlists', 'print_', '_assertCountEqual', '__builtins__', 'sys', 'Module_six_moves_urllib_error', 'Module_six_moves_urllib_request', 'assertRegex', 'MovedModule', 'create_bound_method', '_urllib_robotparser_moved_attributes', '_func_closure', 'indexbytes', 'string_types', 'with_metaclass', 'reraise', 'exec_', 'assertRaisesRegex', 'types', 'python_2_unicode_compatible', 'get_function_globals', '_LazyModule', '_assertRaisesRegex', '_meth_self', 'itertools', '_LazyDescr', 'BytesIO', 'add_move', 'iterbytes', '_func_defaults', '__file__', 'unichr', 'get_method_function', 'create_unbound_method', 'get_unbound_function', 'Module_six_moves_urllib_response', 'functools', '__doc__', 'assertCountEqual', 'integer_types', 'PY34', '_importer', '__spec__', '_urllib_response_moved_attributes', 'Iterator', 'StringIO', '_import_module', '__package__', '__version__', 'get_function_defaults', 'operator', 'PY3', 'MAXSIZE', 'int2byte', '_urllib_request_moved_attributes', '_urllib_parse_moved_attributes', 'b', 'class_types', 'next', 'itervalues', '_add_doc', 'viewkeys', 'MovedAttribute', 'advance_iterator', '__cached__', 'u', '__loader__', '_func_globals', 'get_method_self', 'PY2', 'iterkeys', 'wraps', '_meth_func', 'byte2int', 'io', 'viewitems', 'viewvalues', '__name__', 'get_function_closure', 'binary_type', 'add_metaclass', '_assertRegex']
>>> six.__version__
'1.10.0'

Therefore you can get the version of six by

 python -c "import six; print (six.__version__)"
like image 31
Haifeng Zhang Avatar answered Oct 20 '22 21:10

Haifeng Zhang