Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
/usr/local/bin/bpython
(venv)$ type bpython
bpython is hashed (/usr/local/bin/bpython)
(venv)$ pip install bpython 
(venv)$ which bpython
/Users/lorin/.virtualenvs/venv/bin/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
add comment

2 Answers

up vote 4 down vote accepted

You can tell bash to rehash:

hash -r
share|improve this answer
add comment

Resetting the PATH variable will do it:

export PATH=$PATH
share|improve this answer
add comment

Your Answer

 
discard

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.