I've installed some packages during the execution of my script as a user. Those packages were the first user packages, so python didn't add ~/.local/lib/python2.7/site-packages
to the sys.path
before script run. I want to import those installed packages. But I cannot because they are not in sys.path
.
How can I refresh sys.path
?
I'm using python 2.7.
As explained in What sets up sys.path with Python, and when?
sys.path
is populated with the help of builtinsite.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:That's it.
It might be better to add it directly to your
sys.path
with:Or, if it needs to be found first: