Installing Anaconda Python on CentOS 8

29/12/2020
Anaconda is a Python distribution designed for data science, machine learning, deep learning etc.  In this article, I am going to show you how to install Anaconda Python 2 and Anaconda Python 3 on CentOS 8. So, let’s get started.

Downloading Anaconda Python:

Anaconda Python is not available in the official package repository of CentOS 8. But, you can easily download it from the official website of Anaconda Python and install on your CentOS 8 machine.

First, visit the official website of Anaconda Python. Once the page loads, click on Download.

Now, click on Download.

You should see the following download page. You can download Anaconda Python 3 (3.7 at the time of this writing) or Anaconda Python 2 (2.7 at the time of this writing) depending on your requirements.

Unless you’ve some specific requirements, you won’t need Anaconda Python 2. You will most likely want Anaconda Python 3.

To download Anaconda Python 3, click on the Download link as marked in the screenshot below.

The same way, you can click on the Download link for Python 2 (2.7 at the time of this writing) in order to download Anaconda Python 2.

Now, select Save File and click on OK.

Your browser should start downloading Anaconda Python installer. It may take a while to complete.

Installing Anaconda Python 3:

In this section, I am going to show you how to install Anaconda Python 3.

First, navigate to the ~/Downloads directory as follows:

$ cd ~/Downloads

Anaconda Python 3 installer Anaconda3-2019.10-Linux-x86_64.sh should be there as you can see in the screenshot below.

$ ls -lh

Now, add executable permission to the Anaconda Python 3 installer Anaconda3-2019.10-Linux-x86_64.sh with the following command:

$ chmod +x Anaconda3-2019.10-Linux-x86_64.sh

As you can see, the Anaconda Python 3 installer script is now executable.

Now, start the Anaconda Python 3 installer as follows:

$ ./Anaconda3-2019.10-Linux-x86_64.sh

Now, press <Enter> to continue the installation.

Now, press the <Space Bar> a few times to go to the end of the license agreement.

Once you’re at the end of the license agreement, you should see the following prompt.

Type in yes and press <Enter> to accept the license agreement.

Now, type in a directory where you want to install Anaconda Python 3. The default installation location is ~/anaconda3 (in your HOME directory).

Once you’re done, press <Enter>.

Anaconda Python 3 is being installed. It may take a while to complete.

Once Anaconda Python 3 is installed, you will be asked whether you want add Anaconda Python 3 to the PATH or not.

Type in yes and press <Enter> to add Anaconda Python 3 to the PATH.

Anaconda Python 3 should be added to the PATH.

Now, close the Terminal and open a new one for the changes to take effect.

Now, run the following command to verify whether Anaconda Python 3 is accessible.

$ conda –version

As you can see, I can access Anaconda Python commands. So, it’s working.

In order to use Anaconda Python 3, all you have to do is to use the python3 interpreter to run your program.

$ python3 path/to/python3-script

But, in order to confirm that the python3 interpreter is indeed the Anaconda version of Python 3, start the Python 3 interactive shell as follows:

$ python3

It should show you Anaconda, Inc. on linux as marked in the screenshot below. So, it is the Anaconda version.

Now, press <Ctrl> + D or type in exit() and press <Enter> to exit out of the Python 3 interactive shell.

You can also access your normal Python 3 interpreter (that comes with CentOS 8 by default).

Type in python3 and press <Tab> twice. You should see a list of all your Python 3 interpreters.

Here, python3, python3.7 and python3.7m interpreters are from Anaconda Python 3. You can use any of them to start Anaconda Python 3.

python3.6 and python3.6m interpreters are the CentOS 8 defaults. These are not from Anaconda Python 3.

To confirm that python3.6 and python3.6m interpreters are indeed the CentOS 8 defaults, start the Python 3 interactive shell using python3.6 command as follows:

$ python3.6

Red Hat 8.x.y-z on linux should be printed on the screen as you can see in the screenshot below.

So, you can run a Python script with Anaconda Python 3 as follows:

$ python3 path/to/python3-script

You can run a Python script with normal Python 3 interpreter as follows:

$ python3.6 path/to/python3-script

Installing Anaconda Python 2:

You can install Anaconda Python 2 the same way. Just download the Anaconda Python 2 installer and follow the same steps as Anaconda Python 3 installation.

First, navigate to the ~/Downloads directory as follows:

$ cd ~/Downloads

Anaconda Python 2 installer script Anaconda2-2019.10-Linux-x86_64.sh should be there.

$ ls -lh

Now, add executable permission to the Anaconda Python 2 installer script Anaconda2-2019.10-Linux-x86_64.sh as follows:

$ chmod +x Anaconda2-2019.10-Linux-x86_64.sh

Now, start the Anaconda Python 2 installer as follows:

$ ./Anaconda2-2019.10-Linux-x86_64.sh

Now, press <Enter> to continue.

Press <Space Bar> a few times.

Now, type in yes and press <Enter> to accept the license agreement.

Type in a directory path if you want to change the default installation path ~/anaconda2.

Once you’re done, press <Enter>.

Now, type in yes and press <Enter> to add Anaconda Python 2 to the PATH.

Anaconda Python 2 should be installed.

You can access Anaconda Python 2 interactive shell as follows:

$ python2

As you can see, it is the Anaconda version of Python 2.

You can run a Python script with Anaconda Python 2 as follows:

$ python2 /path/to/python_script

So, that’s how you install Anaconda Python 2 and Anaconda Python 3 on CentOS 8. Thanks for reading this article.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Nextcloud [Part 2] – Cài đặt Nextcloud trên Ubuntu 18

Mục lục Chuẩn bị môi trường Cài đặt dịch vụ Web Cài đặt MariaDB Cài đặt PHP 7.2 Cài...
30/12/2020

Nextcloud [Part 4] – Quản lý File và Thư mục trên NextCloud

Mục lục Quản lý thư mục Quản lý file Phân quyền sử dụng cho người dùng 1. Tạo và...
30/12/2020

Hướng dẫn reset password bằng Single mode trên Linux (#2)

Ở bài viết trước, Onet đã hướng dẫn các bạn cách reset password trên CentOS bằng Single mode. Trong...
30/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Mua proxy v4 chạy socks5 để chơi game an toàn, tốc độ cao ở đâu?
18/05/2024

Thuê mua proxy Telegram trọn gói, tốc độ cao, giá siêu hời
18/05/2024

Thuê mua proxy Viettel ở đâu uy tín, chất lượng và giá tốt? 
14/05/2024

Dịch vụ thuê mua proxy US UK uy tín, chất lượng số #1
13/05/2024

Thuê mua proxy Việt Nam: Báo giá & các thông tin MỚI NHẤT
13/05/2024