0

Assuming I write a python package that has to use the imp module, and my package is "TestModule" which is the following:

import imp
import pip
import sys

def update_and_reload(module, *args, **kwargs):
    pip.main(['install', module, '--upgrade', '--user'])
    return imp.reload(module)

When I do import TestModule in the terminal, I get a pending deprecation warning on imp. How would I make imp's warning not occur / filter out?

13steinj
  • 427
  • 2
  • 9
  • 16

1 Answers1

4

Well you could use the warning module:

import warnings

with warnings.catch_warnings():
    warnings.filterwarnings("ignore", category=DeprecationWarning)
    import imp
import pip
...    
Igor Pejic
  • 3,658
  • 1
  • 14
  • 32