ImportError: cannot import name wraps
See original GitHub issueI am getting an ImportError any time I run tests where I use mock. I’m using mock 1.3.0.
The error is ImportError: cannot import name wraps. It doesn’t seem that installing mock requires six in setup.py when it probably should. And if it requires a specific version of six (one that has a function called wraps) then it should specify that as well.
Looks like I’m not the only one with this issue: http://stackoverflow.com/questions/31417964/importerror-cannot-import-name-wraps
Traceback:
ImportError: Failed to import test module: my_app.tests.test_forms
Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", line 254, in _find_tests
module = self._get_module_from_name(name)
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", line 232, in _get_module_from_name
__import__(name)
File "/Users/grant/my_app/tests/test_forms.py", line 2, in <module>
from mock import patch, MagicMock
File "/Users/grant/.virtualenvs/sidekick/lib/python2.7/site-packages/mock/__init__.py", line 2, in <module>
import mock.mock as _mock
File "/Users/grant/.virtualenvs/sidekick/lib/python2.7/site-packages/mock/mock.py", line 68, in <module>
from six import wraps
ImportError: cannot import name wraps
Issue Analytics
- State:
- Created 8 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
ImportError: cannot import name wraps - python - Stack Overflow
I'm using python 2.7.6 on Ubuntu 14.04.2 LTS. I'm using mock to mock some unittests and noticing when I import mock it fails...
Read more >[#STORM-3390] Lock python test dependencies so we don't ...
... File "/home/travis/.local/lib/python2.7/site-packages/mock/mock.py", line 69, in <module> from six import wraps ImportError: cannot import name wraps.
Read more >How to Fix : “ImportError: Cannot import name X” in Python
In Python "ImportError: cannot import name" error generally occurs when the imported class is not accessible, or the imported class is in a...
Read more >[Solved] ImportError: Cannot Import Name - Python Pool
ImportError occurs when a file cannot load the module, its classes, or methods in a python file. Now, there may be several reasons...
Read more >[Answered]-VirtualEnv cannot import name wraps-django
... import Lock File "/opt/python2.6/lib/python2.6/threading.py", line 13, in <module> from functools import wraps ImportError: cannot import name wraps.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Ugh, that was the problem for me. I had six installed twice in:
/usr/lib/python2.7/dist-packages/and in/usr/local/lib/python2.7/dist-packages/After I removed the six from
/usr/lib/it worked fine:rm /usr/lib/python2.7/dist-packages/*six*@vitalybe I have the same issue with the two paths…