IPython – Установка
IPython по умолчанию включен в дистрибутив Python для Anaconda. Его можно загрузить со страницы загрузки Anaconda www.anaconda.com/download/. Двоичные файлы для всех основных ОС (Windows, MacOS и Linux) и архитектуры (32-разрядных и 64-разрядных) доступны по этой ссылке.
Чтобы установить IPython отдельно в стандартной установке Python, вы можете использовать команду pip, как показано ниже:
IPython внутренне использует следующие пакеты –
Кроссплатформенный API для печати цветного терминального текста из Python
Инструмент автозаполнения для Python
pickleshare
Небольшая «полка», похожая на хранилище данных с поддержкой параллелизма
prompt_toolkit
Библиотека для создания мощных интерактивных командных строк в Python
Пакет с подсветкой синтаксиса, написанный на Python
simplegeneric
Простые общие функции
Система настройки для приложений Python.
Кроссплатформенный API для печати цветного терминального текста из Python
Инструмент автозаполнения для Python
pickleshare
Небольшая «полка», похожая на хранилище данных с поддержкой параллелизма
prompt_toolkit
Библиотека для создания мощных интерактивных командных строк в Python
Пакет с подсветкой синтаксиса, написанный на Python
simplegeneric
Простые общие функции
Система настройки для приложений Python.
В общем, все зависимости устанавливаются автоматически. Иначе, вы можете установить их индивидуально, используя pip.
Quickstart¶
If you have pip , the quickest way to get up and running with IPython is:
This will download and install IPython and its main optional dependencies for the notebook, qtconsole, tests, and other functionality. Some dependencies (Qt, PyQt for the QtConsole, pandoc for nbconvert) are not pip-installable, and will not be pulled in by pip.
To run IPython’s test suite, use the iptest command:
Overview¶
This document describes in detail the steps required to install IPython, and its various optional dependencies. For a few quick ways to get started with package managers or full Python distributions, see the install page of the IPython website.
IPython is organized into a number of subpackages, each of which has its own dependencies. All of the subpackages come with IPython, so you don’t need to download and install them separately. However, to use a given subpackage, you will need to install all of its dependencies.
Please let us know if you have problems installing IPython or any of its dependencies.
IPython and most dependencies can be installed via pip. In many scenarios, this is the simplest method of installing Python packages. More information about pip can be found on its PyPI page.
More general information about installing Python packages can be found in Python’s documentation.
Installing IPython itself¶
Given a properly built Python, the basic interactive IPython shell will work with no external dependencies. However, some Python distributions (particularly on Windows and OS X), don’t come with a working readline module. The IPython shell will work without readline , but will lack many features that users depend on, such as tab completion and command line editing. If you install IPython with pip , then the appropriate readline for your platform will be installed. See below for details of how to make sure you have a working readline .
Installation using pip¶
If you have pip , the easiest way of getting IPython is:
Installation from source¶
If you don’t want to use pip, or don’t have it installed, grab the latest stable build of IPython from here. Then do the following:
If you are installing to a location (like /usr/local ) that requires higher permissions, you may need to run the last command with sudo.
Installing the development version¶
It is also possible to install the development version of IPython from our Git source code repository. To do this you will need to have Git installed on your system. Then do:
Some users want to be able to follow the development branch as it changes. If you have pip , you can replace the last step by:
This creates links in the right places and installs the command line script to the appropriate places.
Then, if you want to update your IPython at any time, do:
IPython now uses git submodules to ship its javascript dependencies. If you run IPython from git master, you may need to update submodules once in a while with:
Another option is to copy git hooks to your ./git/hooks/ directory to ensure that your submodules are up to date on each pull.
Basic optional dependencies¶
There are a number of basic optional dependencies that most users will want to get. These are:
- readline (for command line editing, tab completion, etc.)
- nose (to run the IPython test suite)
- mock (Python < 3, also for tests)
If you are comfortable installing these things yourself, have at it, otherwise read on for more details.
IPython uses several other modules, such as pexpect and path.py, if they are installed on your system, but it can also use bundled versions from IPython.external , so there’s no need to install them separately.
readline¶
As indicated above, on Windows, to get full functionality in the console version of IPython, PyReadline is needed. PyReadline is a separate, Windows only implementation of readline that uses native Windows calls through ctypes . The easiest way of installing PyReadline is you use the binary installer available here.
On OS X, if you are using the built-in Python shipped by Apple, you will be missing a proper readline implementation as Apple ships instead a library called libedit that provides only some of readline’s functionality. While you may find libedit sufficient, we have occasional reports of bugs with it and several developers who use OS X as their main environment consider libedit unacceptable for productive, regular use with IPython.
Therefore, IPython on OS X depends on the gnureadline module. We will not consider completion/history problems to be bugs for IPython if you are using libedit.
To get a working readline module on OS X, do (with pip installed):
Other Python distributions on OS X (such as Anaconda, fink, MacPorts) already have proper readline so you likely don’t have to do this step.
When IPython is installed with pip , the correct readline should be installed if you specify the terminal optional dependencies:
To run the IPython test suite you will need the nose package. Nose provides a great way of sniffing out and running all of the IPython tests. The simplest way of getting nose is to use pip:
Another way of getting this is to do:
For more installation options, see the nose website.
Once you have nose installed, you can run IPython’s test suite using the iptest command:
Dependencies for IPython.parallel (parallel computing)¶
IPython’s inter-process communication uses the PyZMQ bindings for the ZeroMQ messaging library. This is the only dependency for IPython.parallel .
PyZMQ provides wheels for current Python on OS X and Windows, so installing pyzmq will typically not require compilation.
Как установить ipython через git bash
If you have pip , the quickest way to get up and running with IPython is:
This will download and install IPython and its main optional dependencies for the notebook, qtconsole, tests, and other functionality. Some dependencies (Qt, PyQt for the QtConsole, pandoc for nbconvert) are not pip-installable, and will not be pulled in by pip.
To run IPython’s test suite, use the iptest command:
Overview¶
This document describes in detail the steps required to install IPython, and its various optional dependencies. For a few quick ways to get started with package managers or full Python distributions, see the install page of the IPython website.
IPython is organized into a number of subpackages, each of which has its own dependencies. All of the subpackages come with IPython, so you don’t need to download and install them separately. However, to use a given subpackage, you will need to install all of its dependencies.
Please let us know if you have problems installing IPython or any of its dependencies.
IPython and most dependencies can be installed via pip. In many scenarios, this is the simplest method of installing Python packages. More information about pip can be found on its PyPI page.
More general information about installing Python packages can be found in Python’s documentation.
Installing IPython itself¶
Given a properly built Python, the basic interactive IPython shell will work with no external dependencies. However, some Python distributions (particularly on Windows and OS X), don’t come with a working readline module. The IPython shell will work without readline , but will lack many features that users depend on, such as tab completion and command line editing. If you install IPython with pip , then the appropriate readline for your platform will be installed. See below for details of how to make sure you have a working readline .
Installation using pip¶
If you have pip , the easiest way of getting IPython is:
Installation from source¶
If you don’t want to use pip, or don’t have it installed, grab the latest stable build of IPython from here. Then do the following:
If you are installing to a location (like /usr/local ) that requires higher permissions, you may need to run the last command with sudo.
Installing the development version¶
It is also possible to install the development version of IPython from our Git source code repository. To do this you will need to have Git installed on your system. Then do:
Some users want to be able to follow the development branch as it changes. If you have pip , you can replace the last step by:
This creates links in the right places and installs the command line script to the appropriate places.
Then, if you want to update your IPython at any time, do:
IPython now uses git submodules to ship its javascript dependencies. If you run IPython from git master, you may need to update submodules once in a while with:
Another option is to copy git hooks to your ./git/hooks/ directory to ensure that your submodules are up to date on each pull.
Basic optional dependencies¶
There are a number of basic optional dependencies that most users will want to get. These are:
- readline (for command line editing, tab completion, etc.)
- nose (to run the IPython test suite)
- mock (Python < 3, also for tests)
If you are comfortable installing these things yourself, have at it, otherwise read on for more details.
IPython uses several other modules, such as pexpect and path.py, if they are installed on your system, but it can also use bundled versions from IPython.external , so there’s no need to install them separately.
readline¶
As indicated above, on Windows, to get full functionality in the console version of IPython, PyReadline is needed. PyReadline is a separate, Windows only implementation of readline that uses native Windows calls through ctypes . The easiest way of installing PyReadline is you use the binary installer available here.
On OS X, if you are using the built-in Python shipped by Apple, you will be missing a proper readline implementation as Apple ships instead a library called libedit that provides only some of readline’s functionality. While you may find libedit sufficient, we have occasional reports of bugs with it and several developers who use OS X as their main environment consider libedit unacceptable for productive, regular use with IPython.
Therefore, IPython on OS X depends on the gnureadline module. We will not consider completion/history problems to be bugs for IPython if you are using libedit.
To get a working readline module on OS X, do (with pip installed):
Other Python distributions on OS X (such as Anaconda, fink, MacPorts) already have proper readline so you likely don’t have to do this step.
When IPython is installed with pip , the correct readline should be installed if you specify the terminal optional dependencies:
To run the IPython test suite you will need the nose package. Nose provides a great way of sniffing out and running all of the IPython tests. The simplest way of getting nose is to use pip:
Another way of getting this is to do:
For more installation options, see the nose website.
Once you have nose installed, you can run IPython’s test suite using the iptest command:
Dependencies for IPython.parallel (parallel computing)¶
IPython’s inter-process communication uses the PyZMQ bindings for the ZeroMQ messaging library. This is the only dependency for IPython.parallel .
PyZMQ provides wheels for current Python on OS X and Windows, so installing pyzmq will typically not require compilation.
Python: установка и использование IPython
IPython — интерактивная оболочка для языка программирования Python, которая предоставляет расширенную интроспекцию, дополнительный командный синтаксис, подсветку кода и автоматическое дополнение. Является компонентом пакета программ SciPy. (c) Wiki
Однако, на CentOS 6.5, в котором используется:
установка через pip невозможна, так как:
ERROR: IPython requires Python version 2.7 or 3.3 or above.
Поэтому – установим через yum .
Нам потребуется подключенный репозиторий Epel:
Кроме того, нам потребуется отдельно установить модуль argparse :
После чего можно запускать консоль IPython:
Краткий HowTo по IPython
Быстрое получение справки:
Просмотр истории ввода – стрелки вверх/вниз;
Смена текущей директории:
Прсомотр содержимого директории:
Выполенние внешних скриптов:
Автоподстановка команд и/или имен файлов, пути – <TAB> ;
Автоподстановка имен модулей – <TAB> :
Просмотр всех функций модуля:
Получение справочной информации по модулю:
Получение информации по конкретной функции/методу:
И работа, как в обычной консоли Python:
Различие в том, что IPython устанавливат отступы автоматически, тогда как в обычной консоли Python – их необходимо задавать вручную.
Quickstart¶
If you have setuptools , the quickest way to get up and running with IPython is:
This will download and install IPython and its main optional dependencies:
- jinja2, needed for the notebook
- sphinx, needed for nbconvert
- pyzmq, needed for IPython’s parallel computing features, qt console and notebook
- pygments, used by nbconvert and the Qt console for syntax highlighting
- tornado, needed by the web-based notebook
- nose, used by the test suite
- readline (on OS X) or pyreadline (on Windows), needed for the terminal
To run IPython’s test suite, use the iptest command:
Overview¶
This document describes in detail the steps required to install IPython, and its various optional dependencies. For a few quick ways to get started with package managers or full Python distributions, see the install page of the IPython website.
IPython is organized into a number of subpackages, each of which has its own dependencies. All of the subpackages come with IPython, so you don’t need to download and install them separately. However, to use a given subpackage, you will need to install all of its dependencies.
Please let us know if you have problems installing IPython or any of its dependencies.
IPython and most dependencies can be installed via pip. In many scenarios, this is the simplest method of installing Python packages. More information about pip can be found on its PyPI page.
On Windows, IPython requires setuptools . We hope to change this in the future, but for now on Windows, you must install setuptools to use IPython.
More general information about installing Python packages can be found in Python’s documentation.
Installing IPython itself¶
Given a properly built Python, the basic interactive IPython shell will work with no external dependencies. However, some Python distributions (particularly on Windows and OS X), don’t come with a working readline module. The IPython shell will work without readline , but will lack many features that users depend on, such as tab completion and command line editing. If you install IPython with setuptools , (e.g. with pip ), then the appropriate readline for your platform will be installed. See below for details of how to make sure you have a working readline .
Installation using pip¶
If you have setuptools or pip , the easiest way of getting IPython is to simply use pip:
Installation from source¶
If you don’t want to use pip, or don’t have it installed, just grab the latest stable build of IPython from here. Then do the following:
If you are installing to a location (like /usr/local ) that requires higher permissions, you may need to run the last command with sudo.
Windows¶
As mentioned above, on Windows, IPython requires setuptools , and it also requires the PyReadline library to properly support coloring and keyboard management (features that the default windows console doesn’t have). So on Windows, the installation procedure is:
- Install setuptools.
- Install pyreadline. You can use the command pip install pyreadline from a terminal, or the binary installer appropriate for your platform from the PyPI page.
- Install IPython itself, which you can download from PyPI or from our site. Note that on Windows 7, you must right-click and ‘Run as administrator’ for the Start menu shortcuts to be created.
IPython by default runs in a terminal window, but the normal terminal application supplied by Microsoft Windows is very primitive. You may want to download the excellent and free Console application instead, which is a far superior tool. You can even configure Console to give you by default an IPython tab, which is very convenient to create new IPython sessions directly from the working terminal.
Installing the development version¶
It is also possible to install the development version of IPython from our Git source code repository. To do this you will need to have Git installed on your system. Then just do:
Some users want to be able to follow the development branch as it changes. If you have setuptools installed, this is easy. Simply replace the last step by:
This creates links in the right places and installs the command line script to the appropriate places.
Then, if you want to update your IPython at any time, just do:
IPython now uses git submodules to ship its javascript dependencies. If you run IPython from git master, you may need to update submodules once in a while with:
Another option is to copy git hooks to your ./git/hooks/ directory to ensure that your submodules are up to date on each pull.
Basic optional dependencies¶
There are a number of basic optional dependencies that most users will want to get. These are:
- readline (for command line editing, tab completion, etc.)
- nose (to run the IPython test suite)
If you are comfortable installing these things yourself, have at it, otherwise read on for more details.
IPython uses several other modules, such as pexpect and path.py, if they are installed on your system, but it can also use bundled versions from IPython.external , so there’s no need to install them separately.
readline¶
As indicated above, on Windows, to get full functionality in the console version of IPython, PyReadline is needed. PyReadline is a separate, Windows only implementation of readline that uses native Windows calls through ctypes . The easiest way of installing PyReadline is you use the binary installer available here.
On OSX, if you are using the built-in Python shipped by Apple, you will be missing a proper readline implementation as Apple ships instead a library called libedit that provides only some of readline’s functionality. While you may find libedit sufficient, we have occasional reports of bugs with it and several developers who use OS X as their main environment consider libedit unacceptable for productive, regular use with IPython.
Therefore, IPython on OS X depends on the gnureadline module. We will not consider completion/history problems to be bugs for IPython if you are using libedit.
To get a working readline module on OS X, just do (with pip installed):
Other Python distributions on OS X (such as Anaconda, fink, MacPorts) already have proper readline so you likely don’t have to do this step.
When IPython is installed with setuptools , (e.g. using the pip command), the correct readline should be installed if you specify the terminal optional dependencies:
To run the IPython test suite you will need the nose package. Nose provides a great way of sniffing out and running all of the IPython tests. The simplest way of getting nose is to use pip:
Another way of getting this is to do:
For more installation options, see the nose website.
Once you have nose installed, you can run IPython’s test suite using the iptest command:
Dependencies for IPython.parallel (parallel computing)¶
IPython.parallel provides a nice architecture for parallel computing, with a focus on fluid interactive workflows. These features require just one package: PyZMQ. See the next section for PyZMQ details.
On a Unix style platform (including OS X), if you want to use setuptools , you can just do:
Security in IPython.parallel is provided by SSH tunnels. By default, Linux and OSX clients will use the shell ssh command, but on Windows, we also support tunneling with paramiko.
Dependencies for IPython.kernel.zmq¶
pyzmq¶
IPython 0.11 introduced some new functionality, including a two-process execution model using ZeroMQ for communication. The Python bindings to ZeroMQ are found in the PyZMQ project, which is pip install-able. If you are on Python 2.7, 3.3, or 3.4 on OSX or Windows, pyzmq has eggs and wheels that include ZeroMQ itself.
IPython.kernel.zmq depends on pyzmq >= 2.2.
Dependencies for the IPython QT console¶
pyzmq¶
Like the IPython.parallel package, the QT Console requires ZeroMQ and PyZMQ.
Also with 0.11, a new GUI was added using the work in IPython.kernel.zmq , which can be launched with ipython qtconsole . The GUI is built on Qt, and works with either PyQt, which can be installed from the PyQt website, or PySide, from Nokia.
pygments¶
The syntax-highlighting in ipython qtconsole is done with the pygments project, which is pip install-able.
Dependencies for the IPython HTML notebook¶
The IPython notebook is a notebook-style web interface to IPython and can be started with the command ipython notebook .
pyzmq¶
Like the IPython.parallel and IPython.frontend.qt.console packages, the HTML notebook requires ZeroMQ and PyZMQ.
Tornado¶
The IPython notebook uses the Tornado project for its HTTP server. Tornado 2.1 is required, in order to support current versions of browsers, due to an update to the websocket protocol.
Jinja¶
The IPython notebook uses the Jinja templating tool to render HTML pages.
MathJax¶
The IPython notebook uses the MathJax Javascript library for rendering LaTeX in web browsers. Because MathJax is large, we don’t include it with IPython. Normally IPython will load MathJax from a CDN, but if you have a slow network connection, or want to use LaTeX without an internet connection at all, you can install MathJax locally.
A quick and easy method is to install it from a python session:
If you need tighter configuration control, you can download your own copy of MathJax from http://www.mathjax.org/download/ — use the MathJax-2.0 link. When you have the file stored locally, install it with:
For unusual needs, IPython can tell you what directory it wants to find MathJax in:
By default Mathjax will be installed in your ipython profile directory, but you can make system wide install, please refer to the documentation and helper function of IPython.external.mathjax
Browser Compatibility¶
The IPython notebook is officially supported on the following browsers:
- Chrome ≥ 13
- Safari ≥ 5
- Firefox ≥ 6
The is mainly due to the notebook’s usage of WebSockets and the flexible box model.
The following browsers are unsupported:
- Safari < 5
- Firefox < 6
- Chrome < 13
- Opera (any): CSS issues, but execution might work
- Internet Explorer < 10
The following specific combinations are known NOT to work:
- Safari, IPython 0.12, tornado ≥ 2.2.0
- Safari with HTTPS connection to notebook and an untrusted certificate (websockets will fail)
- The diigo Chrome extension seems to interfere with scrolling
There are some early reports that the Notebook works on Internet Explorer 10, but we expect there will be some CSS issues related to the flexible box model.
Dependencies for nbconvert (converting notebooks to various formats)¶
pandoc¶
The most important dependency of nbconvert is Pandoc 1.10 or later, a document format translation program. This is not a Python package, so it cannot be expressed as a regular IPython dependency with setuptools.
Как установить ipython через git bash
IPython по умолчанию включен в дистрибутив Python для Anaconda. Его можно загрузить со страницы загрузки Anaconda www.anaconda.com/download/. Двоичные файлы для всех основных ОС (Windows, MacOS и Linux) и архитектуры (32-разрядных и 64-разрядных) доступны по этой ссылке.
Чтобы установить IPython отдельно в стандартной установке Python, вы можете использовать команду pip, как показано ниже:
IPython внутренне использует следующие пакеты –
Кроссплатформенный API для печати цветного терминального текста из Python
Инструмент автозаполнения для Python
pickleshare
Небольшая «полка», похожая на хранилище данных с поддержкой параллелизма
prompt_toolkit
Библиотека для создания мощных интерактивных командных строк в Python
Пакет с подсветкой синтаксиса, написанный на Python
simplegeneric
Простые общие функции
Система настройки для приложений Python.
Кроссплатформенный API для печати цветного терминального текста из Python
Инструмент автозаполнения для Python
pickleshare
Небольшая «полка», похожая на хранилище данных с поддержкой параллелизма
prompt_toolkit
Библиотека для создания мощных интерактивных командных строк в Python
Пакет с подсветкой синтаксиса, написанный на Python
simplegeneric
Простые общие функции
Система настройки для приложений Python.
В общем, все зависимости устанавливаются автоматически. Иначе, вы можете установить их индивидуально, используя pip.
Setting up Windows for Python¶
There are a number of Python distributions available – many designed for easier support of scientific programming:
- Anaconda
- Enthought Canopy
- Python(x,y)
- etc….
But for basic use, the installer from python.org is the way to go, and that is what we will be using in this program.
You want the installer for Python 3.7 – probably 64 bit, though if you have a 32 bit system, you can get that.
There is essentially no difference for the purposes of this course.
Double click and install.
Ensure that the Install launcher for all users (recommended) and the Add Python 3.7 to PATH checkboxes at the bottom are checked.
Add Python 3.7 to PATH step is important! If this is not checked then when you try to run your python code it won’t be able to find the executable.
Terminal¶
If you are confident in your use of the “DOS Box” or “powershell”, command lines, feel free to use one of those. However, your life may be easier if you install “Git Bash”, as then you can follow unix-style terminal instructions exactly, and do not have to translate. Also, your instructors are more experienced with Bash.
From now on, if you hear the terms “bash”, “shell” or “terminal”, or “command line” know that this is the application that is being referred to. We will use those terms interchangeably to mean ANY command line.
When you install Git Bash, you are installing git (and a git gui) as well, thus killing two birds with one stone!
Select the download button on the page and launch downloaded executable, then follow the prompts. On “Choosing default editor used by Git” step it is best to select Notepad++ (which you need to have installed first) unless you are comfortable with non-graphical editors like vim. You can go through the rest of the prompts using default values. Once you are done, a terminal window should pop up — try out some commands like ls or git help .
You can use this git with the DOS box or Powershell as well.
This is also a good bet for running Python – If you use the Git Bash shell, you can use the same commands as Linux and OS-X users. Regardless of which shell you choose, you will need to add Python to your environment. It is possible that this was done during the installation of Python. If you type ‘which python’ into your terminal, and get back the answer ‘/c/python37/python’, then you are good to go, otherwise (which shouldn’t happen if you checked the “Add Python 3.7 to PATH” checkbox when you installed Python above), follow the instructions here:
You will want to add:
Here are steps for updating path:
You can edit this file using Notepad, locate this file in File Explorer in This PC > Local Disk > Users > YourUsername
Add to the file (file should be empty):
Note: your python executable may be located in a different path, to check the path you need to start windows shell ( cmd ) and type where python — this command will output where python is currently installed.
Save the file and start a new gitbash shell.
Once you have done that, you should be able to type python at the command prompt, and get something like:
This is the Python interpreter.
Type ctrl+Z to get out (or exit() )
Note: if you have trouble running python command in your gitbash (it hangs), try running this instead: winpty python . To avoid having to type winpty python all the time, it’s strongly recommended that you create an alias like below:
You will need to close the current bash window and restart a new one to get this alias. Then from now on, you can just type python and it should work on git bash (no more hanging) as well.
If you installed Git Bash, you will already have git, both usable in the terminal and as a gui, and can safely skip this section. If not, you still need a git client. You can use the above link and install git (it will install the bash shell as well, of course, but you can use your shell of choice instead).
There is also TortoiseGit:
Which integrates git with the file manager. Feel free to use this if you already have an understanding of how git works, but for the purposes of learning, it may be better to use a command line client (git Bash above).
pip is the Python package installer. It is updated faster than Python itself, so once you have Python you want to get the latest version of pip working:
It should download and install the latest pip .
You can now use pip to install other packages.
The first thing you may want to do is update pip itself:
Using pip:¶
To use pip to install a package, you invoke it with this command:
Where python is the command you use to invoke the Python you want to use .
NOTE: You will frequently see advice to use pip like so:
Which often works, but also can invoke the wrong version of pip. The above command:
calls Python, and tells it to run the pip module. It is exactly the same as calling pip directly, except that you are assured that you are getting the version of pip connected the version of Python that you are running.
iPython¶
One extra package we are going to use from the beginning in the program is iPython :
(It will install a LOT)
You should now be able to run iPython from the git bash shell or “DOS Box” or PowerShell:
We will use this in class as our default Python interpreter.
Testing it out¶
- python
- pip
- iPython
- git
All available from the command line.
To try it out, you should be able to run all of these commands, and get something like the following results:
(recall that you can get out of the python or iPython command lines with ctrl+Z (if that doesn’t work, try ctrl+D – the *nix version))
Installing IPython¶
IPython 6 requires Python ≥ 3.3. IPython 5.x can be installed on Python 2.
Quick Install¶
With pip already installed :
This installs IPython as well as its dependencies.
If you want to use IPython with notebooks or the Qt console, you should also install Jupyter pip install jupyter .
Overview¶
This document describes in detail the steps required to install IPython. For a few quick ways to get started with package managers or full Python distributions, see the install page of the IPython website.
Please let us know if you have problems installing IPython or any of its dependencies.
IPython and most dependencies should be installed via pip. In many scenarios, this is the simplest method of installing Python packages. More information about pip can be found on its PyPI page.
More general information about installing Python packages can be found in Python’s documentation.
Dependencies¶
IPython relies on a number of other Python packages. Installing using a package manager like pip or conda will ensure the necessary packages are installed. Manual installation without dependencies is possible, but not recommended. The dependencies can be viewed with package manager commands, such as pip show ipython or conda info ipython.
Installing IPython itself¶
IPython requires several dependencies to work correctly, it is not recommended to install IPython and all its dependencies manually as this can be quite long and troublesome. You should use the python package manager pip .
Installation using pip¶
Make sure you have the latest version of pip (the Python package manager) installed. If you do not, head to Pip documentation and install pip first.
The quickest way to get up and running with IPython is to install it with pip:
Installation from source¶
To install IPython from source, grab the latest stable tarball of IPython from PyPI. Then do the following:
Do not invoke setup.py directly as this can have undesirable consequences for further upgrades. We do not recommend using easy_install either.
If you are installing to a location (like /usr/local ) that requires higher permissions, you may need to run the last command with sudo. You can also install in user specific location by using the —user flag in conjunction with pip.
To run IPython’s test suite, use the pytest command:
Installing the development version¶
It is also possible to install the development version of IPython from our Git source code repository. To do this you will need to have Git installed on your system.
The pip install -e . command allows users and developers to follow the development branch as it changes by creating links in the right places and installing the command line scripts to the appropriate locations.
Then, if you want to update your IPython at any time, do:
If the dependencies or entrypoints have changed, you may have to run
again, but this is infrequent.
© Copyright The IPython Development Team. Revision daa7eb27 . Last updated on Feb 28, 2023.
Как установить ipython через git bash
There are a number of Python distributions available – many designed for easier support of scientific programming:
- Anaconda
- Enthought Canopy
- Python(x,y)
- etc….
But for basic use, the installer from python.org is the way to go, and that is what we will be using in this program.
You want the installer for Python 3.7 – probably 64 bit, though if you have a 32 bit system, you can get that.
There is essentially no difference for the purposes of this course.
Double click and install.
Ensure that the Install launcher for all users (recommended) and the Add Python 3.7 to PATH checkboxes at the bottom are checked.
Add Python 3.7 to PATH step is important! If this is not checked then when you try to run your python code it won’t be able to find the executable.
Terminal¶
If you are confident in your use of the “DOS Box” or “powershell”, command lines, feel free to use one of those. However, your life may be easier if you install “Git Bash”, as then you can follow unix-style terminal instructions exactly, and do not have to translate. Also, your instructors are more experienced with Bash.
From now on, if you hear the terms “bash”, “shell” or “terminal”, or “command line” know that this is the application that is being referred to. We will use those terms interchangeably to mean ANY command line.
When you install Git Bash, you are installing git (and a git gui) as well, thus killing two birds with one stone!
Select the download button on the page and launch downloaded executable, then follow the prompts. On “Choosing default editor used by Git” step it is best to select Notepad++ (which you need to have installed first) unless you are comfortable with non-graphical editors like vim. You can go through the rest of the prompts using default values. Once you are done, a terminal window should pop up — try out some commands like ls or git help .
You can use this git with the DOS box or Powershell as well.
This is also a good bet for running Python – If you use the Git Bash shell, you can use the same commands as Linux and OS-X users. Regardless of which shell you choose, you will need to add Python to your environment. It is possible that this was done during the installation of Python. If you type ‘which python’ into your terminal, and get back the answer ‘/c/python37/python’, then you are good to go, otherwise (which shouldn’t happen if you checked the “Add Python 3.7 to PATH” checkbox when you installed Python above), follow the instructions here:
You will want to add:
Here are steps for updating path:
You can edit this file using Notepad, locate this file in File Explorer in This PC > Local Disk > Users > YourUsername
Add to the file (file should be empty):
Note: your python executable may be located in a different path, to check the path you need to start windows shell ( cmd ) and type where python — this command will output where python is currently installed.
Save the file and start a new gitbash shell.
Once you have done that, you should be able to type python at the command prompt, and get something like:
This is the Python interpreter.
Type ctrl+Z to get out (or exit() )
Note: if you have trouble running python command in your gitbash (it hangs), try running this instead: winpty python . To avoid having to type winpty python all the time, it’s strongly recommended that you create an alias like below:
You will need to close the current bash window and restart a new one to get this alias. Then from now on, you can just type python and it should work on git bash (no more hanging) as well.
If you installed Git Bash, you will already have git, both usable in the terminal and as a gui, and can safely skip this section. If not, you still need a git client. You can use the above link and install git (it will install the bash shell as well, of course, but you can use your shell of choice instead).
There is also TortoiseGit:
Which integrates git with the file manager. Feel free to use this if you already have an understanding of how git works, but for the purposes of learning, it may be better to use a command line client (git Bash above).
pip is the Python package installer. It is updated faster than Python itself, so once you have Python you want to get the latest version of pip working:
It should download and install the latest pip .
You can now use pip to install other packages.
The first thing you may want to do is update pip itself:
Using pip:¶
To use pip to install a package, you invoke it with this command:
Where python is the command you use to invoke the Python you want to use .
NOTE: You will frequently see advice to use pip like so:
Which often works, but also can invoke the wrong version of pip. The above command:
calls Python, and tells it to run the pip module. It is exactly the same as calling pip directly, except that you are assured that you are getting the version of pip connected the version of Python that you are running.
iPython¶
One extra package we are going to use from the beginning in the program is iPython :
(It will install a LOT)
You should now be able to run iPython from the git bash shell or “DOS Box” or PowerShell:
We will use this in class as our default Python interpreter.
Testing it out¶
- python
- pip
- iPython
- git
All available from the command line.
To try it out, you should be able to run all of these commands, and get something like the following results:
(recall that you can get out of the python or iPython command lines with ctrl+Z (if that doesn’t work, try ctrl+D – the *nix version))
Как установить ipython через git bash
Installing Python 3 in Git Bash on Windows 10
Assuming you’ve already installed git bash, here’s how to install Python 3, my preferred scripting language:
- Browse to https://www.python.org/downloads/windows/
- Click on the link for the Latest Python 3 Release
- Click on the Windows x86-64 executable installer and save it in your Downloads directory
- Run the installer from Windows Explorer
- Check the Add Python 3.8 to Path check box
- Click Customize installation
- All Optional Features should already be checked; click Next
- Check Install for all users, then click Install
- When prompted, allow the installer to modify your system
- If the installation fails saying “Another installation is already in progress”, follow the steps in this Microsoft post: https://answers.microsoft.com/en-us/windows/forum/windows_10-other_settings/error-installing-python-another-installation-is-in/b60165dd-ac53-4cfa-86f1-a0f8d53cb5d5. The second suggestion worked for me. On Windows 10, replace Command Prompt (Admin) with Windows PowerShell (Admin).
- Once installed, open a newgit bash window (otherwise, the PATH change will not be in effect)
- Run: python -V
- The result should be (possibly with a newer version): Python 3.8.5
Note: This installation will supersede any installation of Python 2.7. If you have a lot of python 2 specific code and don’t want to port it, here’s an old post on Installing Python 2.7 on Windows. I advise against trying to use PowerShell. Git bash is far superior.
Installing IPython¶
IPython 6 requires Python ≥ 3.3. IPython 5.x can be installed on Python 2.
Quick Install¶
With pip already installed :
This installs IPython as well as its dependencies.
If you want to use IPython with notebooks or the Qt console, you should also install Jupyter pip install jupyter .
Overview¶
This document describes in detail the steps required to install IPython. For a few quick ways to get started with package managers or full Python distributions, see the install page of the IPython website.
Please let us know if you have problems installing IPython or any of its dependencies.
IPython and most dependencies should be installed via pip. In many scenarios, this is the simplest method of installing Python packages. More information about pip can be found on its PyPI page.
More general information about installing Python packages can be found in Python’s documentation.
Dependencies¶
IPython relies on a number of other Python packages. Installing using a package manager like pip or conda will ensure the necessary packages are installed. Manual installation without dependencies is possible, but not recommended. The dependencies can be viewed with package manager commands, such as pip show ipython or conda info ipython.
Installing IPython itself¶
IPython requires several dependencies to work correctly, it is not recommended to install IPython and all its dependencies manually as this can be quite long and troublesome. You should use the python package manager pip .
Installation using pip¶
Make sure you have the latest version of pip (the Python package manager) installed. If you do not, head to Pip documentation and install pip first.
The quickest way to get up and running with IPython is to install it with pip:
Installation from source¶
To install IPython from source, grab the latest stable tarball of IPython from PyPI. Then do the following:
Do not invoke setup.py directly as this can have undesirable consequences for further upgrades. We do not recommend using easy_install either.
If you are installing to a location (like /usr/local ) that requires higher permissions, you may need to run the last command with sudo. You can also install in user specific location by using the —user flag in conjunction with pip.
To run IPython’s test suite, use the pytest command:
Installing the development version¶
It is also possible to install the development version of IPython from our Git source code repository. To do this you will need to have Git installed on your system.
The pip install -e . command allows users and developers to follow the development branch as it changes by creating links in the right places and installing the command line scripts to the appropriate locations.
Then, if you want to update your IPython at any time, do:
If the dependencies or entrypoints have changed, you may have to run
again, but this is infrequent.
© Copyright The IPython Development Team. Revision 311a3a0f . Last updated on Sep 06, 2022.