Cannot import name 'MappingProxyType' error after importing functools
The accepted solution forces you to rename your module, but:
There's nothing wrong with having a module named types
in your package, actually you'll get this error if the interpreter is run with either the current directory or a PYTHONPATH
directory is set to the directory containing the module.
If you avoid this situation, you won't have to rename your module.
If you use an IDE, check the run configuration to make sure PYTHONPATH
or current directory isn't set to include your modules.
This is not a real answer, but a comment.
First: I can't verify the problem presented: The code within the question works perfectly in the standard python I am using.
Second: I stumbled upon this question because I had the same error message, but maybe for a different reason. I accidentally named a module "type". Strangely the python framework selected this new "type" module while resolving references from within imported system modules. Which indicates that python's algorithm of resolving references is a bit ... well ... of a bit of very simple design.
Nevertheless if readers get this error message please check first if you accidentally named something "type" somewhere in your code as a first approach to solve the problem before checking other reasons for that error message.
Update: This is a quite common phenomenon in Python. Be careful! Whenever you give your module a name that has already been used for any imported Python module (and you might not be aware of these names!) you will have the chance of getting strange errors more or less similar to the one described in the question.