Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install a Python package from within IPython?

I wonder if it's possible to install python packages without leaving the IPython shell.

like image 528
satoru Avatar asked Dec 29 '11 01:12

satoru


1 Answers

See the accepted answer from @Chronial which is the best way to do this in modern ipython or jupyter (as of 2018) is to use the %pip magic:

%pip install my_package 

The answer below from 2011 is now outdated: See the accepted answer for an easier way to do this in modern jupyter.

You can use the ! prefix like this:

!pip install packagename 

The ! prefix is a short-hand for the %sc command to run a shell command.

You can also use the !! prefix which is a short-hand for the %sx command to execute a shell command and capture its output (saved into the _ variable by default).

like image 61
aculich Avatar answered Sep 23 '22 15:09

aculich