2

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?

2 Answers 2

7

You can tell bash to rehash:

hash -r
0

Resetting the PATH variable will do it:

export PATH=$PATH

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.