DJANGO cannot import name _compare_digest

Pavol Lisy pavol.lisy at gmail.com
Fri Jun 30 07:32:04 EDT 2017


On 6/28/17, Xristos Xristoou <saxri89 at gmail.com> wrote:
> i dont have 'operator.py' in my system only 'test_operator.py' and
> 'fix_operator.py'
>
> if :
> import sys
> print sys.modules['operator']
>
> i get this :
> 	
> that say me <module 'operator' (built-in)>
>
> how to rename it?
> --
> https://mail.python.org/mailman/listinfo/python-list

Something interesting here!

I just tried to simulate your problems:

python 2.7.12

>>> import logging as operator  # I want to mask operator module
>>> from operator import _compare_digest as compare_digest  # WHAT?
>>> operator.__name__  # OK
'logging'
>>> operator._compare_digest  # OK
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute '_compare_digest'
>>> compare_digest.__name__  # ?
'_compare_digest'
>>> compare_digest.__class__  # ?
<type 'builtin_function_or_method'>
>>> compare_digest.__module__  # ?
'operator'
>>> operator.log.__module__  # OK
'logging'


python 3.6.1 works as I expected

>>> import logging as operator
>>> from operator import _compare_digest as compare_digest
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name '_compare_digest'



More information about the Python-list mailing list