getsentry / raven-python

Raven is the legacy Python client for Sentry (getsentry.com) — replaced by sentry-python
https://sentry.io
BSD 3-Clause "New" or "Revised" License
1.68k stars 657 forks source link

fix import on Python 2.7 #1202

Closed Gustry closed 6 years ago

Gustry commented 6 years ago

I started using Raven inside a QGIS plugin : https://github.com/qgis/QGIS

QGIS 2.18 is using Python 2.7 (until QGIS 3 which will come soon with Python 3).

But I had to change the way contextlib is imported in my Python 2.7 environment:

import sys
sys.version_info
sys.version_info(major=2, minor=7, micro=10, releaselevel='final', serial=0)
import contextlib2 as contextlib
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 607, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
ImportError: No module named contextlib2
import contextlib

The last import works perfectly on Python 2.7 on Windows and Mac.

Gustry commented 6 years ago

It seems it's coming from QGIS.