Python is an object-oriented interpreted computer programming language. Its use has the characteristics of cross-platform. It can be used in Linux, macOS, and Windows systems. When the code written by it runs on different platforms, it is almost impossible Major changes are required, and users all benefit from its convenience.
In addition, the power of Python lies in its wide range of applications, covering artificial intelligence, scientific computing, web development, system operation and maintenance, big data and cloud computing, finance, game development, etc. The prerequisite for realizing its powerful functions is that Python has a large number of standard libraries and third-party libraries with relatively complete functions. Through reference to the library, the development of different fields of business can be realized. However, it is precise because of the huge number of libraries that managing these libraries and maintaining them in time has become an important but highly complex thing.
What is Anaconda?
Anaconda is an integrated Python environment. It can be regarded as an integrated installation of Python that provides python, IPython, an integrated development environment Spyder and many packages, and modules out of the box. The best thing it is quite easy to install even a novice can install it with just one click on windows, macOS, and Linux operating systems.
Anaconda’s individual edition which is open source and free to download and use can be got from its official website.
Anaconda has the following characteristics:
- Simple installation process
- High performance using Python and R language
- Free community support
- Cloud-based repository with over 7,500 data science and machine learning packages
- 1,000+ open source libraries
- ML/AI pipeline in a central development environment, which can be expanded from laptops to thousands of nodes
- Environment manager
- Conda package
- Open source Anaconda Distribution is the easiest way to perform Python/R data science and machine learning
- Develop and train machine learning and deep learning models using sci-kit-learn, TensorFlow and Theano
- Use Dask, NumPy, pandas, and Numba to analyze data with scalability and performance
- Use Matplotlib, Bokeh, Datashader, and Holoviews to visualize the result
The script of the Anaconda to install it is available on the official website, thus anyone can get it from there. After that, the process of Anaconda installation for Ubuntu 20.04,18.04,16.04, RedHat, CentOS 8/7, Debian, Kali Linux, Linux Mint, Fedora, and more, will be the same.
Go to the official download page of Anaconda and get the individual edition available in a 64-bit installation script for Linux operating systems. The size of the script will be around 550 MB.
Run Anaconda3 Installation Script on Ubuntu or CentOS
It doesn’t matter whether you are on Ubuntu 20.04/18.04, CentOS 8/7, or any other Linux operating system, the execution of the script to install the Anaconda on your system will be the same.
If you have downloaded it using the browser, then the installation script will automatically go to the Downloads folder thus switch to that. Or to the folder where you have saved it.
Now, use the following syntax
The filename is the name of the Anaconda Linux installation script. In our case it was Anaconda3-2020.07-Linux-x86_64.sh, thus the command will be:
Accept the terms and conditions
The installer will ask you to accept the terms and conditions, which would be a long list. So, if you don’t want to go through it, simply press
Ctrl+C and then press
Y to accept that.
[email protected]:~/Downloads$ bash Anaconda3-2020.07-Linux-x86_64.sh Welcome to Anaconda3 2020.07 In order to continue the installation process, please review the license agreement. Please, press ENTER to continue >>> =================================== End User License Agreement - Anaconda Individual Edition =================================== Copyright 2015-2020, Anaconda, Inc. All rights reserved under the 3-clause BSD License: This End User License Agreement (the "Agreement") is a legal agreement between y ou and Anaconda, Inc. ("Anaconda") and governs your use of Anaconda Individual E dition (which was formerly known as Anaconda Distribution). Subject to the terms of this Agreement, Anaconda hereby grants you a non-exclusi ve, non-transferable license to: * Install and use the Anaconda Individual Edition (which was formerly known as Anaconda Distribution), * Modify and create derivative works of sample source code delivered in Anacon da Individual Edition from Anaconda's repository; and * Redistribute code files in source (if provided to you by Anaconda as source) and binary forms, with or without modification subject to the requirements set forth below. Do you accept the license terms? [yes|no] [no] >>>
Reload Barshrc or Current Shell
To start using Anaconda without login out while maintaining the state of the Current Shell or terminal; reload the bash, in simple words reload your profile without restarting or logging out of the session.
Use the Conda command to know whether the Anaconda is working fine on your system:
The above command will list all packages available in the current environment using the Conda. See more Conda commands (docs).
Create New Anaconda Environments on Linux
If you want to set up a new Anaconda environment for your project, then use the command
So, for example, if we want to create an environment with Python with a name let’s say: “
firstenv“, so that command will be:
conda create -n firstenv
The above command will create an environment without any package, so let’s say we want to create an environment with python and NumPy, thus the command will be:
conda create -n firstenv python numpy
Or you already have an environment to install packages in that:
conda install -n firstenv python numpy scipy
To use any specific version of the package, let’s say Python 3.6, instead of writing the only python specify the version along with it, for example
In this way, we can install whatever available packages we want. Also to activate the environment and start working using the command:
conda activate firstenv
You can learn more about the Anaconda command and setting up environments on the official website documentation page.
If you don’t want to run every time different commands for setting up environments and package installation using the conda then use the Anaconda graphical user interface application called Navigator. Just like Windows and macOS, we can use it on Linux as well.
- Open command terminal
- Click on the Ok and Don’t Show again button of the pop-up message
- Create or Select the existing environment and start building applications or working with your projects.
Those who want a Desktop shortcut can see: How to create Anaconda Navigator Desktop Shortcut
Difference between Anaconda, conda, pip, and virtualenv
- Anaconda is a release version that contains 180+ scientific packages and their dependencies. The scientific packages included include conda, numpy, scipy, ipython notebook, etc.
- conda is a management tool for packages and their dependencies and environment.
- Applicable platforms: Windows, macOS, Linux
- Quickly install, run and upgrade packages and their dependencies.
- Easily create, save, load, and switch environments on the computer.
If the package you need requires a different version of Python, you don’t need to switch to a different environment, because conda is also an environment manager. With just a few commands, you can create a completely independent environment to run different Python versions, while continuing to use your usual Python version in your regular environment. —— conda official website
- conda was created for the Python project but can be applied to multiple languages mentioned above.
- The conda package and environment manager are included in all versions of Anaconda.
- pip is a package manager for installing and managing software packages.
- Pip writing language: Python.
- The version installed by default in Python:
- Python 2.7.9 and later versions: installed by default, the command is
- Python 3.4 and later versions: installed by default, the command is
- Python 2.7.9 and later versions: installed by default, the command is
- The origin of the pip name: pip uses a recursive abbreviation to name it. Its name is generally believed to come from 2 sources:
- “Pip installs Packages” (“pip install packages”)
- “Pip installs Python” (“pip installs Python”)
- virtualenv: A tool for creating an independent Python environment.
- Solve the problem:
- When one program needs to use Python 2.7 version, and another program needs to use Python 3.6 version, how to use both programs at the same time?
- If all programs are installed in the default path of the system, such as:
/usr/lib/python2.7/site-packagesif you accidentally upgrade a program that should not be upgraded, it will affect other programs.
- If you want to install a program and modify its library or library version while the program is running, the program will be interrupted.
- When sharing the host, the
site-packagespackage cannot be installed in the global catalog.
- virtualenv will create an environment for its own installation directory, it does not with other shared libraries virtualenv environment; but also can selectively be connected to the global library is not installed.
⑤ Comparison of pip and conda
→ Dependency check
- It may not necessarily show other required dependencies.
- When installing the package, it may simply ignore the dependencies and install it, only prompting errors in the results.
- List other required dependencies.
- The dependencies are automatically installed when the package is installed.
- You can easily switch between different versions of the package.
→ Environmental Management
- pip: It is difficult to maintain multiple environments.
- conda: It is more convenient to switch between different environments, and environment management is relatively simple.
→ Impact on the system’s built-in Python
- pip: **Update/rollback version/uninstallation of the Python package in the system will affect other programs.
- conda: Will not affect the system’s built-in Python.
→ Applicable language
- pip: Only for Python.