Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove an imported python module [duplicate]

Tags:

python

Possible Duplicate:
Unload a module in Python

After importing Numpy, lets say I want to delete/remove numpy import reference

import sys  import numpy as np   doMe()    np.something()  #unimport np #remove numpy from memory 
like image 603
Merlin Avatar asked Jan 08 '12 20:01

Merlin


People also ask

How do I delete an imported module in Python?

To remove an imported module in Python: Use the del statement to delete the sys reference to the module. Use the del statement to remove the direct reference to the module.

Can you Unimport something in Python?

You can use https://pypi.org/project/unimport/, it can find and remove unused imports for you.

Can we import same package twice in Python?

Yes, you can import a class twice in Java, it doesn't create any issues but, irrespective of the number of times you import, JVM loads the class only once.


1 Answers

Unloading a module from Python is not supported.

like image 60
David Heffernan Avatar answered Sep 30 '22 13:09

David Heffernan