Python Forum
ImportError has not raised in pkg_resources module but expected - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: ImportError has not raised in pkg_resources module but expected (/thread-19230.html)



ImportError has not raised in pkg_resources module but expected - tamilselvanvjm - Jun-19-2019

I tried to use pkg_resources module in rbtools but I got exception as No module named _imp.

In python 2.7.15rc1 (/usr/lib/python2.7/dist-packages/pkg_resources), we handled if _imp module is not found then we are importing "imp as _imp" in except block.

try:
import _imp
except ImportError:
# Python 3.2 compatibility
import imp as _imp


Here the issue is, try block doesn't raise exception and not handled in except block to set it from imp module.

Please help to resolve this issue. Thanks in advance!

OS: Ubuntu 18.04


RE: ImportError has not raised in pkg_resources module but expected - Gribouillis - Jun-19-2019

No module named _imp is not an exception, it is an error message. Please post the whole exception traceback.


RE: ImportError has not raised in pkg_resources module but expected - tamilselvanvjm - Jun-19-2019

No module named _imp
*** failed to import extension reviewboard from /home/mercurial-reviewboard-stage: name 'SyncTransport' is not defined

I'm expecting try block should raise if it is not found

But when I try it in console it is raising