How to Install Python Anaconda and Miniconda in CentOS 7
To Install Python Anaconda and Miniconda in CentOS 7
Basically, all the major Linux distributions come up with a base Python package. If you update the core interpreter, it might affect certain OS utilities. However, if you use a third-party distribution, you are free to add/remove packages and update python as much as you want and your os will remain fully operational. In this tutorial, you will be briefed about the method to install Python Anaconda and Miniconda in CentOS 7.
Installing Python Anaconda
A minimum of 3GB disk space is required to download and install Anacondo and all its packages. So, first download the Anaconda installer.
Depending upon preferred python version, you can download the anaconda installer. Here python 3.6 for 64-bit architecture is downloaded.
[[email protected] ~]# wget https://repo.continuum.io/archive/Anaconda3-22.214.171.124-Linux-x86_64.sh --2018-02-08 21:48:29-- https://repo.continuum.io/archive/Anaconda3-126.96.36.199-Linux-x86_64.sh Resolving repo.continuum.io (repo.continuum.io)... 188.8.131.52, 184.108.40.206, 2400:cb00:2048:1::6810:120a, ... . Saving to: ‘ Anaconda3-220.127.116.11-Linux-x86_64.sh.1’ 100%[===================================================================================================> ] 549,434,488 761KB/s in 10m 52s
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.
Towards the end, when it asks if you want to perpend Anaconda to your OS’ s PATH variable, select ‘ Yes’ . This will make running Conda commands a lot easier
[email protected] ~]# sh Anaconda3-18.104.22.168-Linux-x86_64.sh The installer will then begin and proceed with a series of questions. Do you accept the license terms? [yes|no] [no] > > > 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/ PREFIX=/usr/local/anaconda Do you wish the installer to prepend the Anaconda3 install location to PATH in your /root/.bashrc ? [yes|no] [no] > > > yes Appending source /usr/local/anaconda/bin/activate to /root/.bashrc A backup will be made to: /root/.bashrc-anaconda3.bak For this change to become active, you have to open a new terminal. Thank you for installing Anaconda3!
To make the changes take effect, close and then re-open your Terminal window.
Our next step is to test our installation. To test your installation, in your Terminal window run the command
[[email protected] ~]# 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 22.214.171.124 py36hfb0b618_1 . . zict 0.1.2 py36ha0d441b_0 zlib 1.2.11 hfbfcf68_1
If your installation is successful, then it will list all the installed packages in the alphabetical order just like above.
You can confirm with the newly installed Python location by just typing the command
[[email protected] ~]# which python /usr/local/anaconda/bin/python
Or the following command.
[[email protected] ~]# python -V Python 3.6.2 :: Anaconda, Inc.
Anaconda is ready to be used.
By using conda command we can easily manage the packages.
[[email protected] ~]# conda update python anaconda: 126.96.36.199-py36hfb0b618_1 --> custom-py36_0 conda: 4.3.27-py36h2866c0b_0 --> 4.3.29-py36ha26b0c0_0 python: 3.6.2-hdfe5801_15 --> 3.6.3-hc9025b9_1 Proceed ([y]/n)? y
For a smaller server environment with a minimum capacity less than 3GB disk space. Download the Miniconda installer by using the following command.
[[email protected] ~]# wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
Once it is downloaded, you shall run the following command to install it.
[[email protected] ~]# sh Miniconda3-latest-Linux-x86_64.sh Welcome to Miniconda3 4.3.31 In order to continue the installation process, please review the license . installation finished. Do you wish the installer to prepend the Miniconda3 install location to PATH in your /root/.bashrc ? [yes|no] [no] > > > yes Appending source /root/miniconda3/bin/activate to /root/.bashrc A backup will be made to: /root/.bashrc-miniconda3.bak For this change to become active, you have to open a new terminal. Thank you for installing Miniconda3!
To make the changes take effect, just make sure to close and re-open your Terminal window.
If you want to check Miniconda, run the conda comment.
[[email protected] ~]# conda list . . zict 0.1.2 py36ha0d441b_0 zlib 1.2.11 hfbfcf68_1
If your installation is successful, then it will list all the installed packages in the alphabetical order as above.
Uninstalling Python Anaconda/Miniconda
To uninstall Python Anconda/Miniconda, you can just remove the installation folder and remove the environment variables set in .bashrc file. For my installation, it will be just like this.
[[email protected] ~]# rm -rf /usr/local/anaconda/ [[email protected] ~]# rm -rf /usr/local/miniconda/
And finally, you can edit the ~/.bashrc file and remove the following entries added for Anaconda/Miniconda directory from your PATH environment variable
[[email protected] ~]# export PATH=" /usr/local/anaconda/bin:$PATH" [[email protected] ~]# export PATH=" /root/miniconda3/bin:$PATH"
By installing this distribution, you’ re free to add or remove packages and update Python to any new versions as you want, without interfering with your underlying OS.