I am trying to use a package called vcrpy to speed up the execution of my Django application test suite. I am using django 1.7 on Mac, with Python 2.7.
I added the following couple of lines to one of my tests:
import vcr with vcr.use_cassette('recording.yaml'):
As a result, an import error occurs:
import vcr File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/vcr/__init__.py", line 2, in <module> from .config import VCR File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/vcr/config.py", line 6, in <module> from .cassette import Cassette File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/vcr/cassette.py", line 12, in <module> from .patch import CassettePatcherBuilder File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/vcr/patch.py", line 8, in <module> from .stubs import VCRHTTPConnection, VCRHTTPSConnection File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/vcr/stubs/__init__.py", line 9, in <module> from six.moves.http_client import ( ImportError: No module named http_client
The problem code in the VCR package itself:
import six from six.moves.http_client import ( HTTPConnection, HTTPSConnection, HTTPMessage, HTTPResponse, )
The funny thing is: this code works fine when I just run it from a simple python console, but it leads to the ImportError described above in Django or under the django manage.py shell.
Any idea what could be wrong?
(some additional information about the location of the six modules:
When I run the empty python console, I get the following:
Python 2.7.8 (v2.7.8:ee879c0ffa11, Jun 29 2014, 21:07:35) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> >>> import six >>> print six.__file__ /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/six.pyc
Doing the same with import django; django.setup() import django; django.setup() , from manage.py shell leads to exactly the same directory and the same six.pyc file.
)