Главная страница » Как установить ipython через git bash

Как установить ipython через git bash

  • автор:

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))

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.

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.

How to use python interactive mode with git bash

With Windows powershell, simply typing python will put you in interactive mode, but git bash won’t.

winpty Add winpyty at the beginning of the command. └ winpty python This is all you need

ʻExit ()` when exiting interactive mode └ Bracket required

ipython If you want to execute processing in python interactive mode, ipython is recommended. It automatically indents while and for statements. (Indentation remains even if you copy and paste the code)

With normal python, indentation will result in an error if you can’t do it one by one.

How to install ipython

python

Normal python >>> becomes ʻIn [line number]:`.

ʻExit or ʻexit () when exiting interactive mode └ No need for parentheses

### What is pip (supplement) Official python package management system. It is included in python by default.

Something useful (or essential) for using python.

## Create shortcut It’s a hassle to type `winpty python` or` winpty ipython` every time, so Setting an alias (shortcut command) makes it easier to enter interactive mode.

Once you get used to it, it’s easy to set up, and it’s a must-have feature if you use gitbush.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *