permanently remove directory from python path

If the line you mention is in your .bashrc, it should be safe to simply delete it.

Exactly as it stands, what the line says is "add /my/path to PYTHONPATH", so it should be fairly safe even if there are others around your .bashrc.


First, from terminal grab everything in your path by using

env | grep PYTHONPATH

Then, export your path and manually remove anything you no longer need:

export PYTHONPATH=[this is where you paste the corrected paths, no square brackets needed]

If you restart your session and you haven't modified anything in .bashrc, you can simply close and reopen your session.


If you simply delete the line "export PYTHONPATH=..." in .bashrc and do "source .bashrc", those directories would still be in sys.path.

Unlike "export PATH" in .bashrc, it seems that when you export some directories into PYTHONPATH, they are dump into some file which python can always check.

So, what you need to do is "export PYTHONPATH=" (export empty string) and do "source .bashrc". This will clean up everything you have export into PYTHONPATH before in .bashrc.