How to refresh sys.path?
As explained in What sets up sys.path with Python, and when? sys.path
is populated with the help of builtin site.py
module.
So you just need to reload it. You cannot it in one step because you don't have site
in your namespace. To sum up:
import site
from importlib import reload
reload(site)
That's it.