How to Install Python Anaconda 5 on Arch Linux 2017

Python Anaconda Arch LinuxIt can be quite time-consuming to compile all the hundreds of Python modules for your tools for each and every OS environment. Instead, you can use a unified special Python distribution, like Anaconda.

Anaconda is a pre-packaged python development environment with many useful packages for our tasks. It contains conda plus over 720 open source packages, it is the most robust type of installation. We do not need administrative or root permissions to install Anaconda. We can install it for the local user with writable install location or even can be installed server wide with administrator permissions. In our earlier article, we saw how to install anaconda on Centos 7 and Ubuntu 16.04.

In this article, I'll explain how to install Python Anaconda 5/Miniconda in Arch Linux 4.11.7-1 (version 2017.07.01). Let's walk through the installation steps one by one.

Installing Python Anaconda 5 on Arch Linux

Anaconda requires a minimum of 3G disk space to download and install all of its source packages. Before proceeding with this installation, make sure you've installed wget & bzip2 in your server. If not, you just install it by the below command:

# pacman -S bzip2 wget

Next, we need to choose a directory where the new Python binaries will be installed. In this tutorial, we’ll be using the installation path (/usr/local/anaconda). You can change the default installation path to the one which you need during the installation. You can check out these steps on how I installed Python 3.6 using the Anaconda bash installer to the above directory.

Download the installer

Depending on the preferred Python version, you can download the Anaconda installer from Continuum.io. I've downloaded the Anaconda 5 with Python 3.6 for 64-Bit (x86) architecture.

#wget http://repo.continuum.io/archive/Anaconda3-5.0.0-Linux-x86_64.sh

Run the installer

Once you've downloaded the installer, you can open up a terminal and run it. You can run the installer using shell command sh just like this.

#sh Anaconda3-5.0.0-Linux-x86_64.sh

The installer will then begin and proceed with a series of questions. Accepting the Terms and Conditions is pretty self-explanatory. If you are unsure about any setting, accept the defaults. You can change them later. I've changed the default installation path during the installation phase just like this:

Please answer 'yes' or 'no':'
 >>> yes

Anaconda3 will now be installed into this location:
 /root/anaconda3

- Press ENTER to confirm the location
 - Press CTRL-C to abort the installation
 - Or specify a different location below

[/root/anaconda3] >>> /usr/local/anaconda/

Towards the end, when it asks if you want to prepend Anaconda to your OS’s PATH variable, select ‘no’. In Arch Linux we need to Prepend Anaconda to your Path variable manually. This will make running Conda commands a lot easier.

Prepending to the PATH Variable

After installation, we need to prepend Anaconda bin directory to the PATH environment variable. This means that Anaconda’s python and other packages will override Linux’s system python and packages. For this we need to edit the /etc/profile file with the below entries.

You need to add the PATH variable to /etc/profile as below:

# added by Anaconda3 installer
 export PATH="/usr/local/anaconda/bin:$PATH"

To make the changes take effect, close and then re-open your Terminal window.

Testing your installation

Our next step is to test our installation. To test your installation, in your Terminal window run the command conda list. If your installation is successful, then it will list all the installed packages in the alphabetical order just like this.

# conda list
 # packages in environment at /usr/local/anaconda:
 #
 _ipyw_jlab_nb_ext_conf 0.1.0 py36he11e457_0
 alabaster 0.7.10 py36h306e16b_0
 anaconda 5.0.0 py36h06de3c5_0
 anaconda-client 1.6.5 py36h19c0dcd_0

You can confirm with the newly installed Python location by just typing the command which python .

# python -V
 Python 3.6.2 :: Anaconda, Inc.
# which python
 /usr/local/anaconda/bin/python

And there you have it! Anaconda is ready to be used. As mentioned before, using conda command we can easily manage the packages. For instance, we can update any package using conda update [package_name] or install a package using conda install [package_name]. Please see the example below for updating our Python using conda command .

# conda update python
 Fetching package metadata ...........
 Solving package specifications: .

Package plan for installation in environment /usr/local/anaconda:

The following packages will be UPDATED:

anaconda: 5.0.0-py36h06de3c5_0 --> custom-py36hbbc8b67_0
 conda: 4.3.27-py36h2866c0b_0 --> 4.3.30-py36h5d9f9f4_0
 python: 3.6.2-h02fb82a_12 --> 3.6.3-hefd0734_2

Proceed ([y]/n)? y

python-3.6.3-h 100% |###############################################################################################| Time: 0:00:13 2.29 MB/s
 anaconda-custo 100% |###############################################################################################| Time: 0:00:00 2.64 MB/s
 conda-4.3.30-p 100% |###############################################################################################| Time: 0:00:00 3.78 MB/s
 [[email protected] ~]# cat /etc/issue
 Arch Linux \r (\l)

You can get familiar with more of these commands usage using conda commands cheat sheet.

Installing Miniconda 3 on Arch Linux  4.11.7-1

Miniconda is a miniature version of Anaconda that includes only conda and its dependencies. I would prefer Miniconda over Anaconda for a smaller server environment with a maximum capacity of 3GB disk space. This installation is quite fast and easy. Let's walk through the installation steps below:

Download the installer

Depending on the preferred Python version, you can download the Miniconda installer. I've downloaded the Miniconda with Python 3.6 for 64-Bit (x86) architecture.

# wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh

Run the installer

Once you've downloaded the installer, you can open up a terminal and run the installer using shell command sh just like this.

# sh Miniconda3-latest-Linux-x86_64.sh

Similar to the previous installation steps, the installer will then begin and proceed with a series of questions. Accepting the Terms and Conditions, you will be asked for the installation path. If you are unsure about any setting, accept the defaults. You can change them later. I've chosen the installation path as "/usr/local/miniconda".

You can skip the step in which the installer asks you to prepend the Miniconda installation location to your OS's PATH variable.

Please answer 'yes' or 'no':'
 >>> yes
Miniconda3 will now be installed into this location:
 /root/miniconda3

- Press ENTER to confirm the location
 - Press CTRL-C to abort the installation
 - Or specify a different location below

[/root/miniconda3] >>> /usr/local/miniconda/
 PREFIX=/usr/local/miniconda
 installing: python-3.6.3-hc9025b9_1 ...

Do you wish the installer to prepend the Miniconda3 install location
 to PATH in your /root/.bashrc ? [yes|no]
 [no] >>> no

Prepending to the PATH Variable

After installation, we need to prepend Miniconda bin directory to the PATH environment variable. This means that Miniconda’s python and other packages will override Linux’s system python and packages. For this, we need to edit the /etc/profile file with the below entries.

Add this in /etc/profile file

# cat /etc/profile | grep -i miniconda
 # added by Miniconda3 installer
 export PATH="/usr/local/miniconda/bin:$PATH"

To make the changes take effect, close and then re-open your Terminal window.

Testing your installation

To test your installation, in your Terminal window run the command conda list .

If your installation is successful, then it will list all the installed packages in the alphabetical order just like this.

]# conda list
 # packages in environment at /usr/local/miniconda:
 #
 asn1crypto 0.22.0 py36h265ca7c_1
 ca-certificates 2017.08.26 h1d4fec5_0
 certifi 2017.7.27.1 py36h8b7b77e_0
 cffi 1.10.0 py36had8d393_1
 chardet 3.0.4 py36h0f667ec_1
 conda 4.3.30 py36h5d9f9f4_0
 conda-env 2.6.0 h36134e3_1
 cryptography 2.0.3 py36ha225213_1
 idna 2.6 py36h82fb2a8_1
 libedit 3.1 heed3624_0
 libffi 3.2.1 h4deb6c0_3
 libgcc-ng 7.2.0 h7cc24e2_2
 libstdcxx-ng 7.2.0 h7a57d05_2
 ncurses 6.0 h06874d7_1
 openssl 1.0.2l h077ae2c_5
 pip 9.0.1 py36h8ec8b28_3
 pycosat 0.6.2 py36h1a0ea17_1

You can confirm with the newly installed Python location by just typing the command which python.

# python -V
 Python 3.6.3 :: Anaconda, Inc.
 # which python
 /usr/local/miniconda/bin/python

Uninstalling Python Anaconda/Miniconda in ArchLinux

To uninstall Python Anconda/Miniconda, you can just remove the installation folder and remove the environment variables set in /etc/profile file. For my installation, it will be just like this.

rm -rf /usr/local/anaconda *// For Anaconda //*

&

rm -rf /usr/local/miniconda *// For Miniconda //*

And finally, you can edit the /etc/profile file and remove the following entries added for Anaconda/Miniconda directory from your PATH environment variable.

# added by Anaconda3 installer
 export PATH="/usr/local/anaconda/bin:$PATH"

# added by Miniconda3 installer
 export PATH="/usr/local/miniconda/bin:$PATH"

Wrapping up

If you are using Arch Linux, you can simply install and run Anaconda or Miniconda depending on the server capacity. It's a useful cross-platform Python distribution for your tasks, with a lot of packages which can take time to compile when you're using a package manager. Pip and easy_install setup tools can be quite messy to deal with, and even distract from the core tasks at hand. I would strongly recommend using this tool which makes building Python quite easy.

About Saheetha Shameer

I'm working as a Senior System Administrator. I'm a quick learner and have a slight inclination towards following the current and emerging trends in the industry. My hobbies include hearing music, playing strategy computer games, reading and gardening. I also have a high passion for experimenting with various culinary delights :-)

Author Archive Page

Have anything to say?

Your email address will not be published. Required fields are marked *

All comments are subject to moderation.