In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how the analysis of the use of Anaconda is, and the content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
Order
Python is easy to use, but not easy to use. The biggest headache is package management and different versions of Python, especially when you are using Windows. In order to solve these problems, there are many distributions of Python, such as WinPython, Anaconda and so on. These distributions package python and many commonly used package to facilitate the direct use of pythoners. In addition, there are virtualenv, pyenv and other tools to manage the virtual environment.
Individuals tried many similar distributions and finally chose Anaconda because of its powerful and convenient package management and environmental management capabilities. This paper mainly introduces Anaconda, the understanding of Anaconda, and briefly summarizes the related operations.
Overview of Anaconda
Anaconda is a Python distribution for scientific computing, which supports Linux, Mac and Windows systems. It provides the functions of package management and environment management, and can easily solve the problems of multi-version python coexistence, switching and various third-party package installation. Anaconda uses the tool / command conda to manage package and environment, and already includes Python and related supporting tools.
Let's first explain the differences between conda and anaconda. Conda can be understood as a tool and an executable command, and its core functions are package management and environment management. Package management is similar to the use of pip, while environmental management allows users to easily install different versions of python and switch quickly. Anaconda is a packaged collection that comes pre-loaded with conda, a version of python, many packages, scientific computing tools, and so on, so it is also called a distribution of Python. In fact, there is Miniconda, as the name implies, it contains only the most basic content-python and conda, as well as related must dependencies, for users with strict space requirements, Miniconda is a choice.
Before moving on, explain the design philosophy of conda-conda treats almost all tools and third-party packages as package, even python and conda itself! Therefore, conda breaks the constraints of package management and environmental management, and can easily install various versions of python and package and switch between them.
Installation of Anaconda
For the download page of Anaconda, please see the official website, which is supported by Linux, Mac and Windows.
When you install, you will find that there are two different versions of Anaconda, corresponding to Python 2.7and Python 3.5.The two versions are the same except for this difference. As we'll see later, it doesn't matter which version to install, because through environmental management, we can easily switch between runtime versions of Python. (since my commonly used Python is 2.7and 3.4, I prefer to install the Anaconda corresponding to Python 2.7 directly.)
After downloading, you can directly follow the instructions to install. Here is a reminder: try to install according to the default behavior of Anaconda-do not use root permissions, only for personal installation, the installation directory is set in the personal home directory (Windows doesn't matter). The advantage is that different users on the same machine can install and configure their own Anaconda without affecting each other.
For Mac and Linux systems, after Anaconda is installed, there is actually an extra folder (~ / anaconda) in the home directory, and Windows will be written to the registry. During installation, the installer adds the bin directory to PATH (Linux/Mac is written to ~ / .bashrc, Windows is added to the system variable PATH), and you can do this on your own. Take Linux/Mac as an example, the operation to set PATH after installation is
one
two
three
four
# add the bin directory of anaconda to PATH, which may be ~ / anaconda3/bin depending on the version
Echo 'export PATH= "~ / anaconda2/bin:$PATH" > > ~ / .bashrc
# update bashrc to take effect immediately
Source / .bashrc
Once PATH is configured, you can check whether it is correct by using the which conda or conda-- version command. If you install the corresponding version of Python 2.7, you can get Python 2.7.12:: Anaconda 4.1.1 (64-bit) by running python-- version or python-V, which also indicates that the default environment for this distribution is Python 2.7.
Environmental Management of Conda
Conda's environmental management feature allows us to install several different versions of Python at the same time and switch freely. For the above installation process, assuming that we are using the installation package corresponding to Python 2.7, then Python 2.7 is the default environment (the default name is root, note that this root does not mean Super Admin).
Suppose we need to install Python 3.4.At this point, we need to do the following:
# create an environment called python34 and specify Python version 3.4 (regardless of whether 3.4.xMagneConda will automatically find the latest version for us in 3.4.x) conda create-- after name python34 python=3.4# is installed, use activate to activate an environment activate python34 # for Windowssource activate python34 # for Linux & Mac#, you will find that the word python34 is added to the terminal input. In fact, What the system does at this time is to remove the default environment of 2.7from the PATH, and then add the command corresponding to PATH# to PATH#. At this time, type python-- version# again to get `environment 3.4.5:: Anaconda 4.1.1 (64-bit) `, that is, the system has switched to the environment of 3.4.4.If you want to return to the default environment of python 2.7, Run deactivate python34 # for Windowssource deactivate python34 # for Linux & Mac# to delete an existing environment conda remove-name python34-all
Note: some users may often use the python 3.4 environment, so directly add the bin or Scripts under ~ / anaconda/envs/python34 to PATH and remove the bin directory corresponding to anaconda. This method, how to say, is also possible, but I always feel that it is not so elegant. Different python environments installed by the user will be placed in the directory ~ / anaconda/envs. You can run conda info-e in the command to view the installed environment. The currently activated environment will be displayed with an asterisk or parentheses.
If you directly change the PATH as mentioned above, you will find that the conda command can not be found again (of course, because the conda is in ~ / anaconda/bin), what should I do? There are two methods: 1. Explicitly give the absolute address of conda 2. The conda tool is also installed in the python34 environment (recommended).
Package Management of Conda
Conda's package management is easier to understand, and this part of the function is similar to pip.
For example, if you need to install scipy:
# installing scipyconda install scipy# conda will search for information and dependencies of scipy remotely. For python 3.4, numpy and mkl (Compute acceleration Library) will be installed at the same time. # View the latest version of packagesconda list# that has been installed. Conda searches for installed packages from the site-packages folder without relying on pip, so you can display packages installed in various ways.
Some common operations of conda are as follows:
# View the installed package under the current environment conda list# view the installed package conda list-n python34# for a specified environment find package information conda search numpy# install packageconda install-n python34 numpy# if you do not specify the environment name, it is installed in the current active environment # you can also specify by-c to delete the packageconda remove-n python34 numpy through a channel installation # update packageconda update-n python34 numpy
As mentioned earlier, conda treats conda, python, and so on as package, so you can use conda to manage versions of conda and python, such as
# Update conda, keep conda up-to-date conda update conda# update anacondaconda update anaconda# update pythonconda update python# assuming the current environment is python 3.4, conda will upgrade python to the current latest version of the 3.4.x series
Add: if you create a new python environment, such as 3.4.After running conda create-n python34 python=3.4, conda installs only the necessary items related to python 3.4, such as python, pip, etc. If you want this environment to be the same as the default environment, you only need to install the anaconda collection package:
# install anaconda package collection conda install anaconda# in the current environment combined with the command to create an environment. The above operations can be merged into conda create-n python34 python=3.4 anaconda#, or you can install your own package according to your needs without all installation.
Set up a domestic image
If you need to install a lot of packages, you will find that conda downloads are often slow because Anaconda.org 's servers are abroad. Fortunately, Tsinghua TUNA image source has an image of Anaconda repository, so we can add it to the configuration of conda:
# add TUNA image conda config of Anaconda-- the image address in the help of add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/# TUNA is enclosed in quotation marks, which needs to be removed. # set the channel address conda config to be displayed when searching-- set show_channel_urls yes
After executing the above command, a ~ / .condarc (Linux/Mac) or C:UsersUSER_NAME.condarc file is generated, which records our configuration of conda. Creating and editing the file manually has the same effect.
Anaconda has the characteristics of cross-platform, package management and environment management, so it is very suitable for rapid deployment of Python environment on new machines. To sum up, the whole process of installation and configuration is as follows:
Download Anaconda, install
Configure PATH (bashrc or environment variable) to change the TUNA mirror source
Create the required version of the python environment
Just Try!
Cheat-sheet download: Conda cheat sheet
On the use of Anaconda analysis is how to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.