23

Using Python 2.7 installed via homebrew. I then used pip to install IPython. So, IPython seems to be installed under:

/usr/local/lib/python2.7/site-packages/

I think this is true because there is a IPython directory and ipython egg.

However, when I type ipython in the terminal I get:

-bash: ipython: command not found

I do not understand why this ONLY happens with IPython and not with python? Also, how do I fix this? What path should I add in .bashrc? And how should I add?

Currently, my .bashrc reads:

PATH=$PATH:/usr/local/bin/

Thanks!

minrk
  • 37,545
  • 9
  • 92
  • 87
Rohit
  • 5,840
  • 13
  • 42
  • 65
  • Is it actually running the python you installed, as it already had python before you installed another version of it. – demure May 25 '13 at 03:04
  • I added the comment to the main question. – Rohit May 25 '13 at 12:02
  • Find out where the `ipython` script was installed, and if necessary symlink it to somewhere on your PATH. – Thomas K May 25 '13 at 17:08
  • What is it that I look for "ipython installation"? Do I look for .app or .egg? And what command do I use to symlink? Thanks! – Rohit May 25 '13 at 19:13
  • From bash you have to start ipython with the following command: ipython-2.7 (and NOT just with ipython) – Stefan Gruenwald Apr 27 '14 at 04:29
  • For quick reference to answer below by Luna Kong: specify a python module (such as IPython) using the -m parameter: 'python -m IPython'. – mikeborgh Dec 27 '17 at 22:44

8 Answers8

26

I had this issue too, the following worked for me and seems like a clean simple solution:

pip uninstall ipython

pip install ipython

I'm running mavericks and latest pip

robertwest
  • 904
  • 7
  • 13
22

Check IPython whether is installed by below command:

$python -m IPython

enter image description here If you got this result as above picture.

Then run this command on terminal and add into ~/.bash_profile file

$alias ipython='python -m IPython'

So try run "ipython" again on terminal. It works fine for me.

Reference topics:

ipython on MacOS 10.10 - command not found

iPython installed but not found

Luna Kong
  • 3,065
  • 25
  • 20
  • 1
    just had similar issue when updating from Mac OSX Mojave to Catalina and changing to zsh as a standard shell, even in the bash version of it the ipython command was broken, adding alias ipython="python3 -m IPython" to ~/.zshrc fixes it – braulio Oct 05 '20 at 14:20
4

Create .pydistutils.cfg in your homedir with following content:

[global]
verbose=1

[install]
install-scripts=$HOME/bin

[easy_install]
install-scripts=$HOME/bin

And then: pip install -U --user ipython. Of course $HOME/bin must be in your $PATH. Packages are going to be installed in $HOME/Library/Python, so user only, not system wide.

nudzo
  • 17,166
  • 2
  • 19
  • 19
  • Hmm....when I do the pip command as you suggested I get: no such option: --user #I added my account name as user, obviously! Any ideas why the command fails? – Rohit May 26 '13 at 02:06
  • `pip` needs to be installed into homedir too. Run `easy_install --user pip`, to got one in your `$HOME/bin` and then --user option will be enabled. – nudzo May 26 '13 at 09:48
  • Wait, when I try EXACTLY the command you suggested I have the following: pip install -U --user ipython Requirement already up-to-date: ipython in /usr/local/lib/python2.7/site-packages Cleaning up... – Rohit May 26 '13 at 13:35
  • OK, I did the following: easy_install --user pip Searching for pip Best match: pip 1.3.1 Processing pip-1.3.1-py2.7.egg Adding pip 1.3.1 to easy-install.pth file Installing pip script to /Users/XXXX/bin Installing pip-2.7 script to /Users/XXXX/bin where XXXX is the username. I also have the .pydistutils.cfg file in my home directory and still ipython command is not recognized. – Rohit May 26 '13 at 13:39
  • 1
    The run again: `pip install -U --user --force ipython`, to get it reinstalled and scripts put in `$HOME/bin`. – nudzo May 26 '13 at 18:50
  • Yay! That works. Thanks SO MUCH for your patience and perseverance. – Rohit May 26 '13 at 23:53
  • Found this necessary again on El Capitan; thanks for the detailed instructions. – tzaman Jul 05 '16 at 12:42
4

Try run brew install ipython:

enter image description here

then run xcode-select --install

run brew install git,

enter image description here

If you got this result as above picture. Refer to enter link description here

At last, run brew install ipython

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
2

I use pip3 install ipython is OK.

maybe ipython rely on python3

anddju
  • 21
  • 1
0

After trying to a number of solutions like above with out joy, when I restarted my terminal, Ipython command launched. Don't forgot to restart your terminal after all the fiddling!

P.S. I think the brew install Ipython did it ... but can't be sure.

entpnerd
  • 10,049
  • 8
  • 47
  • 68
Always In
  • 25
  • 6
0

For me the only thing that helped was: python -m pip install --upgrade pip

Upgrading pip did the work and all the installations started working properly! Give it a try.

Whitebear
  • 1,761
  • 2
  • 12
  • 22
0

Another way is to find the ipython launcher script that was created when installing ipython via pip and use it.

Find where ipython is by running:

find / -name ipython

You may have to add sudo: sudo find / -name ipython

In my case (macOS: Ventura 3.13, python 3.11 ) this returned:

/Library/Frameworks/Python.framework/Versions/3.11/bin/ipython

Verify that this ipython script works as expected.

Run the whole path in the terminal: /Library/Frameworks/Python.framework/Versions/3.11/bin/ipython. You should see the ipython console prompt

console screenshot of ipython

Next, you need to tell your mac that the command ipython means in fact /Library/Frameworks/Python.framework/Versions/3.11/bin/ipython. You do that by creating a symbolic link in /usr/local/bin/ to the real location of ipython with ln -s <source file> <target file>.

In the terminal run:

ln -s /Library/Frameworks/Python.framework/Versions/3.11/bin/ipython /usr/local/bin/ipython

And ipython now starts an ipython session

ipython starts the ipython console

Alexis Perrier
  • 683
  • 9
  • 13