Tuesday 12 March 2019

[Research] An introduction of Conda, Git, Pip

1. Introduction

Anaconda is a release version of python, of which features are supporting Linux, Mac, Windows and providing environment and package management ability. It is very convenient to switch between multi-version python. In Anaconda, Conda provides Package, dependency and environment management for any language—Python, R, Ruby, Lua, Scala, Java, JavaScript, C/ C++, FORTRAN

Conda is an open source package management system and environmental management system that runs on Windows, macOS and Linux. Conda quickly installs, runs and updates packages and their dependencies. Conda easily creates, saves, loads and switches between environments on your local computer. It was created for Python programs, but it can package and distribute software for any language.

Conda as a package manager helps you find and install packages. If you need a package that requires a different version of Python, you do not need to switch to a different environment manager, because conda is also an environment manager. With just a few commands, you can set up a totally separate environment to run that different version of Python, while continuing to run your usual version of Python in your normal environment.

Apart from conda, pip is the package installer for Python. You can use pip to install packages from the Python Package Index and other indexes.

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

So in this post, I will introduce the difference between those tools.

2. Anaconda

Figure 1. Anaconda installation directory
The general way to install the Anaconda is to download the software on its website. Once choosing the python version and x86/x64, you can directly download and install in your computer. Figure 1 shows the installation directory on my computer.

We see in the main directory, there includes [env] and [python]. The reason why I mention these two is it can show the main feature of the Anaconda in environment management. [python] in this directory means a chosen version python and spyder are already installed. So if you directly choose Spyder from the start. you are using the pre-defined type of python. In this default python, there are many packages already installed there. You can directly import and use it.
Figure 2. package already installed in default.

We can view this default as the base(root) environment. Then I will introduce the environment management of the tool conda.
First I will show you how to create a new environment as shown above:
1) open Anaconda Prompt
2) $conda create --name testpy python=3.6
3) $conda activate testpy
4) $conda install spyder
5) $spyder

Now this testpy has been created under [env] and spyder is also installed. Comparing figure 1 and 3, you will find them almost the same. But they work independently. The packages they use are also independent. That means the packages used by default spyder are not used by testpy. Testpy need to install by itself.
Figure 3. testpy installation directory
Figure 4. package installed for testpy.

3. pip

Generally, conda is mainly used for environment management. Of course, you can also use it to install or uninstall some packages. But here, I want to introduce the tool, pip.

pip is used for install or uninstall packages for python (spyder).
The format of language is: pip install package_name; pip uninstall package_name
attention: there are two ways to directly use pip commands. 1) directly use the command windows [Home + R]; 2) the second is to use Anaconda Prompt and #(base) model
The location of downloading packages is:
Figure 5. Location of installed package
As mentioned before, we created another environment testpy, and we intalled spyder for this environment. we also can use pip to install packages for this environment. The installed location is shown below.
Figure 6. Location of installed package for testpy
In this environment, if we want to use pip install, we need to enter Anaconda Prompt and $(testpy) model. 

conda is also used for install and uninstall packages, but it needs to use Anaconda Prompt.
For default python (spyder), we use $(base) model, for a specific environment like testpy, we use $(testpy).

the commands like:
(testpy) C:\Users\acw393>conda install -n testpy filterpy
(base) C:\Users\acw393>conda install numpy


4. Git











No comments:

Post a Comment

[Research] Recurrent Neural Network (RNN)

1. Introduction As we all know, forward neural networks (FNN) have no connection between neurons in the same layer or in cross layers. Th...