This question already has an answer here:

I've installed ipython inside virtualenv on my macOS. My PATH environment variable also shows virtualenv path to be at the beginning. which command also shows that ipython at the correct location.

The problem is, when I run ipython, the shell is finding the previous installation in an odd place. Here's some examples:

(csv_import) $ ipython
-bash: /usr/local/bin/ipython: /usr/local/opt/python3/bin/python3.6: bad interpreter: No such file or directory
(csv_import) $ 
(csv_import) $ which ipython
(csv_import) $ 
(csv_import) $ echo $PATH
(csv_import) $ 
(csv_import) $ 
(csv_import) $ /Users/zeinep/.virtualenvs/csv_import/bin/ipython
Python 3.6.5 (default, Jun 17 2018, 12:13:06) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.3.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]:         

As can be seen, if I use a full path, it works. Otherwise, old installation at /usr/local/bin/ipython is run even though the shell should be finding the one in in virtualenv as far as I can see.

marked as duplicate by JdeBP, Jeff Schaller bash Feb 28 at 17:23

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • What operating system are you using? Is that macOS? – terdon Feb 28 at 14:54
  • @terdon yes, this is macOS – tayfun Feb 28 at 15:00
  • OK. If you've installed in in a virtualenv, why are you trying to run it outside the virtualenv? Does it work of you do . /Users/zeinep/.virtualenvs/csv_import/bin/activate (or whatever the right command is to activate the virtualenv) and then run ipython? – terdon Feb 28 at 15:02
  • 1
    @JeffSchaller it seems like that solved it! Thanks! – tayfun Feb 28 at 15:02
  • @terdon it's inside virtualenv. That (csv_import) at the beginning is telling me I'm inside the virtual env. – tayfun Feb 28 at 15:03

You apparently added /Users/zeinep/.virtualenvs/csv_import/bin to your $PATH after bash had saved (hashed) the /usr/local/bin version. The fix is as simple as hash -d ipython.

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