Cause Python beginners - Anaconda Getting Started Guide

https://www.jianshu.com/p/169403f7e40c

Learning Python intend to do data analysis you are not at the outset encountered trouble?

  • In the end of the installation Python2 it or Python3?
  • Why always wrong when installing Python?
  • Installation Kit how it?
  • Why does it say you must install a bunch of other tools to know why before installing this tool?

I believe most Python beginners who have environmental problems and a headache, but you are not alone, we are all so frustrating over. In order to avoid detours in the entry, and let the rising enthusiasm would not get hit, where Anaconda is recommended to manage your installation environment and various toolkits.

This article describes the use of Anaconda, the full text of the following outline:

  • Why Anaconda
  • What is Anaconda
  • What is conda
  • Anaconda advantage
  • How to install Anaconda
  • How to manage Python package
  • How to manage Python environment

First, why choose Anaconda?

1.1 What is Anaconda?

Anaconda is focused on the release of Python data analysis, including conda, Python and more than 190 scientific packages and their dependencies. As a curious baby you are not discovered a new term conda , then you will ask conda what is it?

1.2 What is conda?

conda is open source packages (packages) and virtual environments (environment) management systems.

  • Management packages: You can use conda to install, update, uninstall the toolkit, and it is more focused on scientific data related to the toolkit. When installing pre-integrated image on the anaconda Numpy, Scipy, pandas, Scikit- learn those commonly used in the data analysis package. Also worth mentioning is that, conda not only manage Python toolkit, it can also install a non-python package. Integrated Development Environment Rstudio For example, in the new version can be installed in Anaconda R language.

  • Management of virtual environments: in conda can create multiple virtual environments for different versions of different items required isolation kit to prevent conflict on the version. Entangled in the Python version for students, we can also create Python2 and Python3 two environments to run different versions of Python code, respectively.

Know what is (what) at the same time, we also need to ask why the (Why) . So why choose to use Anaconda it?

1.3 Anaconda advantage?

To sum up the advantages of Anaconda to eight words: save time and worry, the analysis tool.

  • Save your money: Anaconda by management toolkits, development environment, Python version, greatly simplifies your workflow. Not only easy to install, update, uninstall the kit, and can automatically install the appropriate dependencies during installation, while using different virtual environments to isolate different project requirements.

  • Analysis tool: in Anaconda official website is so promote their own: for enterprise big data analysis tool Python. It contains more than 720 scientific data related open source packages, data visualization, machine learning, deep learning and other aspects are involved. Not only do the data analysis, and even can be used in big data and artificial intelligence.

Solve what and why the problem after, let's look at how to do (How) .


Second, how to install Anaconda?

From here to download Anaconda installer and installation instructions. Whether it is Windows, Linux or MAC OSX the system, install the software can be found in the corresponding. If your computer is 64-bit then try to choose the 64-bit version. As of Python version 2.7 or 3.x, it is recommended that you use Python3, because Python2 will eventually stop maintenance . Currently on the market most likely to use the tutorials are still Python2, this need not worry, because in Anaconda can manage two versions of the Python environment at the same time.

According to prompts to install, you will probably be surprised to find a lot more computer applications, do not worry after completion, we look at an item:

  • Anaconda Navigator : Kit and for managing a graphical user interface environment, many subsequent management command may be done manually directed in the Navigator.
  • Notebook Jupyter : a web-based interactive computing environment, people can edit a document easy to read and display data for process analysis.
  • qtconsole : a imitation terminal IPython executable GUI program, compared Python Shell interface, qtconsole can directly display the graphic code generation, to realize the input lines of code execution, and many useful functions and built-in functions.
  • Spyder : use a Python language, cross-platform integrated development environment for scientific computing.

After installation is complete, we also need to upgrade kits for all, in order to avoid possible errors. Open your computer terminal, enter the command line:

conda upgrade --all

When asked if the terminal is installed as an upgraded version of the input y.

In some cases, you may encounter an error message conda command is not found, it is likely to be a problem in the environment path settings, you need to add conda environment variables: export PATH=xxx/anaconda/bin:$PATHwhere xxx is replaced by the anaconda installation path.

At this point, the installation is complete, let's look at how to use Anaconda Administration Kit and the environment.


Third, how to manage Python package?

Install a package:

conda install package_name

Here you need to install package_name is the name of the package. You can also install a plurality of packages simultaneously, such as to install numpy, scipy and PANDAS, then the following command:

conda install numpy scipy pandas

You can also specify the installed version, such as installing version 1.1 of numpy:

conda install numpy=1.10

Remove a package:

conda remove package_name

Upgrade package Version:

conda update package_name

See all packages:

conda list

If you can not remember the name of the package, can be fuzzy query:

conda  search search_term

Fourth, how to manage Python environment?

The default setting is root, you can also create a new environment:

conda create -n env_name  list of packages

Which -nrepresents the name, env_nameis the name of the environment needs to be created, list of packagesit is listed in the tool kit in the new environment need to be installed.

For example, when Python3 version of Anaconda I installed, the default root is Python3 natural environment, but I also need to create an environment Python 2 to Python running an older version of the code, the best also installed pandas package, so we run the following command to create:

conda create -n py2 python=2.7 pandas 

Careful you will find, py2 environment not only install the pandas, also installed numpy and a series of packages, this is the use conda at convenience, it will automatically install the appropriate dependencies for you, without requiring you to one install it manually.

Env_name called into the environment of:

source activate env_name

Exit the current environment:

source deactivate

Also note that, in Windows, use activate env_nameand deactivateto enter and exit a particular environment.

Delete called env_name the environment:

conda env remove -n env_name

Show all environments:

conda env list

When sharing the code, but also the need for everyone to share operating environment, execute the following command to package the information in the current environment may be stored in a file named environment in YAML.

conda env export > environment.yaml

Similarly, when performing code others, also you need to configure the environment. Then you can share with each other YAML files to create exactly the same operating environment.

conda env create -f environment.yaml

At this point, you have entered the Anaconda door, follow you can wander the ocean in Python.

I wish a happy learning!


NOTE: This reference code sample from Anaconda Udacity data analysis section of the course.

Guess you like

Origin blog.csdn.net/baidu_37503452/article/details/90643753