question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ImportError: cannot import name wraps

See original GitHub issue

I 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:closed
  • Created 8 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
vitalybecommented, Jul 29, 2015

perhaps print six.path

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*

0reactions
jackiesyucommented, Aug 12, 2015

@vitalybe I have the same issue with the two paths…

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found