Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I often run into the case where I'm working inside a Python virtualenv, and I want to run an executable Python program (e.g., bpython). I run it, forgetting that I have not installed it in my virtualenv so it won't do the right thing. Then, I install bpython in my virtualenv, but if I try to run the new version, bash "remembers" the old one and calls it instead.

To be more concrete:

(venv)$ bpython
       (whoops, system-level bpython!)
(venv)$ which bpython
(venv)$ type bpython
bpython is hashed (/usr/local/bin/bpython)
(venv)$ pip install bpython 
(venv)$ which bpython
(venv)$ type bpython
bpython is hashed (/usr/local/bin/bpython)

How do I tell the bash prompt to "forget" that the location of bpython is /usr/local/bin/bpython for that session?

share|improve this question
up vote 5 down vote accepted

You can tell bash to rehash:

hash -r
share|improve this answer

Resetting the PATH variable will do it:

export PATH=$PATH
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.