Как установить анаконду для питона
Перейти к содержимому

Как установить анаконду для питона

  • автор:

Знакомство с Anaconda: что это такое и как установить

Простое руководство по Anaconda и его установке на Ubuntu 16.04 (64-bit).

Что такое Anaconda?

Перед тем, как изучать Anaconda, рассмотрим Conda.

Цитируем определение Conda с официального блога:

Conda — это менеджер пакетов с открытым кодом и система управления средой, которая работает на Windows, macOS и Linux.

Conda проста в установке, выполнении и обновлении пакетов и зависимостей. Conda легко создает, сохраняет, загружает и переключается между средами на локальном компьютере.

Она задумывалась для программ на Python, но может создавать пакеты и дистрибутивы программного обеспечения на любом языке.

Возникает вопрос: почему вдруг речь зашла о Conda? Все мы знаем, что это система управления пакетами, которая используется для установки и управления пакетов приложений, написанных на Python.

Система имеет и свои ограничения. Ей можно пользоваться только для пакетов Python.

pip работает с Python и пренебрегает зависимостями из не-Python библиотек (HDF5, MKL, LLVM), в исходном коде которых отсутствует файл установщика.

Проще говоря, pip – это менеджер пакетов, который облегчает установку, обновление и удаление пакетов Python. Он работает с виртуальными средами Python.

Conda – это менеджер пакетов для любого программного обеспечения (установка, обновление, удаление). Он работает с виртуальными системными средами.

Conda — это инструмент для управления пакетами и установщик с куда большим функционалом, чем в pip . Conda может обрабатывать зависимости библиотек вне пакетов Python, а также сами пакеты Python.

Кроме того, Conda создает виртуальную среду.

Как возникла Anaconda?

Conda написан на чистом Python, что облегчает его использование в виртуальных средах Python. Кроме того, Conda подходит для библиотек С, пакетов R, Java и т.д.

Он устанавливает двоичные системы. Инструмент conda build создает пакеты из исходного кода, а conda install выполняет установку из пакетов сборки Conda.

Conda является менеджером пакетов для Anaconda — дистрибутива Python, предоставляемого Continuum Analytics. Емкое описание Anaconda следующее:

Anaconda — это дистрибутивы Python и R. Он предоставляет все необходимое для решения задач по анализу и обработке данных (с применимостью к Python).

Anaconda — это набор бинарных систем, включающий в себя Scipy, Numpy, Pandas и их зависимости.

Scipy — это пакет статистического анализа.

Numpy — это пакет числовых вычислений.

Pandas — уровень абстракции данных для объединения и преобразования данных.

Anaconda полезна тем, что объединяет все это в единую систему.

Двоичная система Anaconda — это установщик, который собирает все пакеты с зависимостями внутри вашей системы.

Простая установка

Установка файлов иногда превращается в сущий ад. Но Anaconda куда проще, чем кажется. Я предпочитаю Ubuntu, поскольку здесь установка зависит от выполнения пары команд и хорошего сетевого подключения. Поэтому все становится еще проще. Вот дальнейшие шаги для установки Anaconda.

(Данный процесс подойдет только для 64-битных компьютеров).

Шаг 1: скачивание bash-скрипта Anaconda

Скачать последнюю версию bash-скрипта установщика Anaconda можно с официального сайта. Это можно сделать через выполнение команды curl. Если в вашей системе не установлен curl, то скачайте его через следующую команду.

Перейдите в папку /tmp.

После установки curl выполните следующую команду:

Размер файла — порядка 500 МБ, поэтому установка обычно занимает несколько минут. Пожалуйста, дождитесь полного скачивания файла.

Этот скриншот был сделан после скачивания скрипта. Убедитесь в стабильности сетевого подключения. В противном случае могут возникнуть ошибки при скачивании.

Шаг 2: проверка целостности

Для проверки целостности данных установщика воспользуемся криптографическим алгоритмом хеширования под названием SHA-2 (алгоритм безопасного хеширования).

Контрольная сумма генерируется следующей строкой после выполнения команды.

Шаг 3: запуск bash-скрипта

Мы почти закончили. Пакет загрузился. Теперь осталось запустить скрипт через нужную команду.

На стандартном этапе проверки у вас спросят, хотите ли вы установить Anaconda. Для продолжения установки введите yes .

Шаг 4: установка криптографических библиотек

Это часть предыдущего процесса. Установщик спрашивает у пользователя, хочет ли он установить все криптографические библиотеки. Введите yes и можете продолжать. Ориентируйтесь по скриншоту ниже – вы увидите примерно ту же информацию.

Шаг 5: подтверждение папки

Последним и итоговым шагом является подтверждение папки, куда будут выгружаться все пакеты Anaconda. Укажите путь, нажмите Enter и готово! Anaconda начнет творить чудеса, устанавливая все, что вам нужно!

Installing on Windows¶

Using Anaconda in a commercial setting? You may need to purchase a license to stay compliant with our Terms of Service. This can be accomplished through Anaconda Professional, Anaconda Server, or Anaconda Enterprise. If you have already purchased Professional, please proceed to the Authenticating Anaconda Professional section after completing your installation here.

Haven’t purchased Anaconda Professional yet? Visit https://anaconda.cloud/register to get started.

More of a visual learner? Watch the Installing Anaconda (Windows) video in the course linked below!

../../../_images/learning-ad1.png

Go to your Downloads folder and double-click the installer to launch. To prevent permission errors, do not launch the installer from the Favorites folder .

If you encounter issues during installation, temporarily disable your anti-virus software during install, then re-enable it after the installation concludes. If you installed for all users, uninstall Anaconda and re-install it for your user only.

Click Next.

Read the licensing terms and click I Agree.

It is recommended that you install for Just Me, which will install Anaconda Distribution to just the current user account. Only select an install for All Users if you need to install for all users’ accounts on the computer (which requires Windows Administrator privileges).

Click Next.

Select a destination folder to install Anaconda and click Next. Install Anaconda to a directory path that does not contain spaces or unicode characters. For more information on destination folders, see the FAQ .

Do not install as Administrator unless admin privileges are required.

../../../_images/win-install-destination.png

Choose whether to add Anaconda to your PATH environment variable or register Anaconda as your default Python. We don’t recommend adding Anaconda to your PATH environment variable, since this can interfere with other software. Unless you plan on installing and running multiple versions of Anaconda or multiple versions of Python, accept the default and leave this box checked. Instead, use Anaconda software by opening Anaconda Navigator or the Anaconda Prompt from the Start Menu.

As of Anaconda Distribution 2022.05 , the option to add Anaconda to the PATH environment variable during an All Users installation has been disabled. This was done to address a security exploit. You can still add Anaconda to the PATH environment variable during a Just Me installation.

../../../_images/win-install-options.png

Click Install. If you want to watch the packages Anaconda is installing, click Show Details.

Click Next.

Optional: To install Dataspell for Anaconda, click https://www.anaconda.com/dataspell.

../../../_images/win-install-pycharm.png

Or to continue without Dataspell, click Next.

After a successful installation you will see the “Thanks for installing Anaconda” dialog box:

../../../_images/win-install-complete.png

If you wish to read more about Anaconda.org and how to get started with Anaconda, check the boxes “Anaconda Distribution Tutorial” and “Learn more about Anaconda”. Click the Finish button.

If you are behind a company proxy, you may need to do some additional setup. See how to set up your proxy .

Problems?¶

What’s next?¶

Get started programming with Anaconda in the Getting started with Anaconda guide.

Visit Anaconda Nucleus to start programming for FREE in a notebook. Learn how from Anaconda Learning, too!

Installation¶

Review the system requirements listed below before installing Anaconda Distribution. If you don’t want the hundreds of packages included with Anaconda, install Miniconda, a mini version of Anaconda that includes just conda, its dependencies, and Python.

Looking for Python 3.5 or 3.6? See our FAQ .

System requirements

  • License: Free use and redistribution under the terms of the EULA for Anaconda Distribution.
  • Operating system: Windows 8 or newer, 64-bit macOS 10.13+, or Linux, including Ubuntu, RedHat, CentOS 7+, and others.
  • If your operating system is older than what is currently supported, you can find older versions of the Anaconda installers in our archive that might work for you. See Using Anaconda on older operating systems for version recommendations.
  • System architecture: Windows- 64-bit x86; MacOS- 64-bit x86 & M1; Linux- 64-bit x86, 64-bit aarch64 (AWS Graviton2), 64-bit Power8/Power9, s390x (Linux on IBM Z & LinuxONE).
  • Minimum 5 GB disk space to download and install.

On Windows, macOS, and Linux, it is best to install Anaconda for the local user, which does not require administrator permissions and is the most robust type of installation. However, with administrator permissions, you can install Anaconda system wide.

Silent mode install

Use silent mode to automatically accept default settings and have no screen prompts appear during installation.

Need to use Anaconda on an older operating system?

Installing Anaconda on a non-networked machine (air gap)

  1. Obtain a local copy of the appropriate Anaconda installer for the non-networked machine. You can copy the Anaconda installer to the target machine using many different methods, including a portable hard drive, USB drive, or CD.
  2. After copying the installer to the non-networked machine, follow the detailed installation instructions for your operating system.

Install offline copies of both docs.anaconda.com and enterprise-docs.anaconda.com by installing the conda package anaconda-docs: conda install anaconda-docs

Install offline copies of documentation for many of Anaconda’s open-source packages by installing the conda package anaconda-oss-docs: conda install anaconda-oss-docs

Other ways to get Anaconda or Miniconda

The official Anaconda or Miniconda AMIs are on the AWS Marketplace.

If you have a CDH (Cloudera Distributed Hadoop) cluster, install the Anaconda parcel using Cloudera Manager. The Anaconda parcel provides a static installation of Anaconda, based on Python 2.7, that can be used with Python and PySpark jobs on the cluster.

Troubleshooting

If you experience errors during the installation process, review our Troubleshooting topics .

Getting started with Anaconda¶

Anaconda Distribution contains conda and Anaconda Navigator, as well as Python and hundreds of scientific packages . When you installed Anaconda, you installed all these too.

Conda works on your command line interface such as Anaconda Prompt on Windows and terminal on macOS and Linux.

Navigator is a desktop graphical user interface that allows you to launch applications and easily manage conda packages, environments, and channels without using command-line commands.

You can try both conda and Navigator to see which is right for you to manage your packages and environments. You can even switch between them, and the work you do with one can be viewed in the other.

Try this simple programming exercise, with Navigator and the command line , to help you decide which approach is right for you.

When you’re done, see What’s next? .

Your first Python program: Hello, Anaconda!¶

Use Anaconda Navigator to launch an application. Then, create and run a simple Python program with Spyder and Jupyter Notebook. Watch our short training videos on Anaconda Learning to get up and running with Jupyter Notebook and JupyterLab, along with several other popular integrated development environments (IDEs):

../../../_images/learning-ad2.png

Open Navigator¶

Choose the instructions for your operating system.

Windows

From the Start menu, click the Anaconda Navigator desktop app.

macOS

Open Launchpad, then click the Anaconda Navigator icon.

Linux

Open a terminal window and type anaconda-navigator .

Navigator’s Home page displays several applications for you to choose from. For more information, see links at the bottom of this page.

Run Python in Spyder IDE (integrated development environment)¶

More of a visual learner? Follow along with Create a simple Python program in Spyder on Anaconda Learning instead!

On Navigator’s Home tab, in the Applications pane on the right, scroll to the Spyder tile and click the Install button to install Spyder.

If you already have Spyder installed, you can jump right to the Launch step.

Launch Spyder by clicking Spyder’s Launch button.

In the new file on the left, delete any placeholder text, then type or copy/paste print("Hello Anaconda") .

In the top menu, click File — Save As and name your new program hello.py .

Run your new program by clicking the triangle Run button.

You can see your program’s output in the bottom right Console pane.

../../../_images/getting-started_Spyder.png

Close Spyder¶

From Spyder’s top menu bar, select Spyder — Quit Spyder (In macOS, select Python — Quit Spyder).

Run Python in a Jupyter Notebook¶

More of a visual learner? Watch our short training videos on Jupyter Notebook and JupyterLab on Anaconda Learning instead!

On Navigator’s Home tab, in the Applications pane on the right, scroll to the Jupyter Notebook tile and click the Install button to install Jupyter Notebook.

If you already have Jupyter Notebook installed, you can jump right to the Launch step.

Launch Jupyter Notebook by clicking Jupyter Notebook’s Launch button.

This will launch a new browser window (or a new tab) showing the Notebook Dashboard.

../../../_images/jupyter-dashboard.png

On the top of the right hand side, there is a dropdown menu labeled “New”. Create a new Notebook with the Python version you installed.

Rename your Notebook. Either click on the current name and edit it or find rename under File in the top menu bar. You can name it to whatever you’d like, but for this example we’ll use MyFirstAnacondaNotebook.

In the first line of the Notebook, type or copy/paste print("Hello Anaconda") .

Save your Notebook by either clicking the save and checkpoint icon or select File — Save and Checkpoint in the top menu.

Run your new program by clicking the Run button or selecting Cell — Run All from the top menu.

../../../_images/getting-started_Jupyter.png

Close Jupyter Notebook¶

  1. From Jupyter Notebooks top menu bar, select File — Close and Halt.
  2. Click the Quit button at the upper right of the Notebook Dashboard and close the window or tab.

Close Navigator¶

From Navigator’s top menu bar, select Anaconda Navigator — Quit Anaconda-Navigator.

Write a Python program using Anaconda Prompt or terminal¶

Open Anaconda Prompt¶

Choose the instructions for your operating system.

Windows

From the Start menu, search for and open “Anaconda Prompt”:

macOS

Open Launchpad, then click the terminal icon.

Linux

Open a terminal window.

Start Python¶

At Anaconda Prompt (terminal on Linux or macOS), type python and press Enter.

The >>> means you are in Python.

Write a Python program¶

At the >>> , type print("Hello Anaconda!") and press Enter.

When you press enter, your program runs. The words “Hello Anaconda!” print to the screen. You’re programming in Python!

Exit Python¶

On Windows, press CTRL-Z and press Enter. On macOS or Linux type exit() and press Enter.

Optional: Launch Spyder or Jupyter Notebook from the command line¶

  1. At the Anaconda Prompt (terminal on Linux or macOS), type spyder and press Enter. Spyder should start up just like it did when you launched it from Anaconda Navigator.
  2. Close Spyder the same way you did in the previous exercise.
  3. At the Anaconda Prompt (terminal on Linux or macOS), type jupyter-notebook and press Enter.

Jupyter Notebook should start up just like it did when you launched it from Anaconda Navigator. Close it the same way you did in the previous exercise.

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

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