Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

moto + raven: six issue, cannot import urllib #502

Closed
amitsaha opened this issue Jan 8, 2016 · 9 comments
Closed

moto + raven: six issue, cannot import urllib #502

amitsaha opened this issue Jan 8, 2016 · 9 comments

Comments

@amitsaha
Copy link

amitsaha commented Jan 8, 2016

I tried to use moto in our code base where we also use raven (for sentry logging):

>>> from raven.utils import six
>>> 
>>> from moto import mock_s3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/moto/__init__.py", line 8, in <module>
    from .autoscaling import mock_autoscaling  # flake8: noqa
  File "/usr/local/lib/python2.7/dist-packages/moto/autoscaling/__init__.py", line 2, in <module>
    from .models import autoscaling_backends
  File "/usr/local/lib/python2.7/dist-packages/moto/autoscaling/models.py", line 3, in <module>
    from moto.core import BaseBackend
  File "/usr/local/lib/python2.7/dist-packages/moto/core/__init__.py", line 2, in <module>
    from .models import BaseBackend  # flake8: noqa
  File "/usr/local/lib/python2.7/dist-packages/moto/core/models.py", line 8, in <module>
    from .responses import metadata_response
  File "/usr/local/lib/python2.7/dist-packages/moto/core/responses.py", line 8, in <module>
    import six.moves.urllib
ImportError: No module named urllib

This is not a moto specific issue, however, I thought I would point it here: http://stackoverflow.com/questions/34667533/weird-issue-with-python-six-cannot-import-urllib

If you have any suggestions, please let me know.

@spulec
Copy link
Collaborator

spulec commented Jan 8, 2016

Why are you importing six from raven instead of import six itself?

@amitsaha
Copy link
Author

amitsaha commented Jan 8, 2016

This code simply demonstrates what raven does - which my application code calls before I import moto.

@spulec
Copy link
Collaborator

spulec commented Jan 8, 2016

Ah, got it. If you just run python, can you import six.moves.urllib?

@amitsaha
Copy link
Author

amitsaha commented Jan 8, 2016

Yes. I can. A funny thing is if I import six.moves.urllib before importing raven, everything works.

@spulec
Copy link
Collaborator

spulec commented Jan 8, 2016

What happens if you import Raven and then run import six.moves.urllib?

@amitsaha
Copy link
Author

amitsaha commented Jan 8, 2016

I haven't tried that. Will update on Monday from work. Thank you for working through this with me.

@amitsaha
Copy link
Author

This is what I see:

>>> from raven.utils import six
>>> import six.moves.urllib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named urllib
>>> 
>>> 
>>> import six
>>> 
>>> 
>>> six.moves.urllib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/six.py", line 90, in __get__
    result = self._resolve()
  File "/usr/local/lib/python2.7/dist-packages/six.py", line 113, in _resolve
    return _import_module(self.mod)
  File "/usr/local/lib/python2.7/dist-packages/six.py", line 80, in _import_module
    __import__(name)
ImportError: No module named urllib

I should note that, the six module shipped with raven doesn't actually include the urllib support.

@mitsuhiko
Copy link

Is this python-moto from debian or did you pip install it?

@amitsaha
Copy link
Author

Hi @mitsuhiko , thanks for the hint related to requests on the get sentry email. As i emailed there:

If you install requests-0.14.2 (which I had installed), this error easily surfaces. I upgrade requests and it doesn't happen any more. If you could share why this was happening, I would love to know.

Thanks, closing this issue now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants