Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Installation and use of Anaconda

2025-01-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "the installation and use of Anaconda". In the daily operation, I believe that many people have doubts about the installation and use of Anaconda. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "installation and use of Anaconda". Next, please follow the editor to study!

Anaconda is an open source Python package manager. It is not only a large gift package collection of various Python libraries, but also a tool to create a virtual machine environment. The reason I installed it is because I want to use Python's AkShare library to get the data, which requires Python 3.6 or above. My computer Python 2.7.15, and do not want to upgrade, so install anaconda, use anaconda to create a virtual machine environment, use Python3.6 in the virtual machine environment, the local computer keeps the original version unchanged.

Download address www.anaconda.com Select download

Download the latest version of the installation package Anaconda3-2020.02-Windows-x86_64.exe

The installation directory is selected here, and the environment files for each version of Python created in the future are also placed in a subdirectory of this directory.

Here I checked the bottom, not the top.

Start installation

When the installation is complete, Anaconda prompt will appear at the beginning of the search for ana. I am running as an administrator, and there should be no problem without administrator privileges.

The front (base) indicates that you are in the basic environment of Anaconda, which is generally not really used. You should build your own environment according to your specific project needs, otherwise the power of this tool will be greatly reduced. Comparing the Python version of the base environment with the Python version of the normal command-line tool, you can see that the two do not affect each other.

Many packages need to be downloaded when setting up the environment. If the download speed is slow, the download of timeout will be terminated, and an error will be reported.

The solution is to set channels to the image address of Tsinghua University and execute the following command on the command line. It is recommended that you first set up the following channels, and then create your first environment.

Conda config-add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/conda config-add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/conda config-add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/conda config-add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro/

The command to create your own environment is conda create-n ak_test python=3.7.3. Ak_test is the name of the new environment, whatever you want. 3.7.3 is the version I specified, and you can write whatever version you need.

Here to explain the creation of the ak_test environment is complete, prompting you to use the environment and leave the environment command.

Execute conda activate ak_test and see that (base) becomes (ak_test), indicating that you have entered the ak_test environment.

I set up this environment to use akshare, so install akshare and report an error time out

It should be a domestic network problem. Use Ali Cloud image to install. The command is as follows

Pip install akshare-I http://mirrors.aliyun.com/pypi/simple/-- trusted-host=mirrors.aliyun.com-- upgrade

Installation successful!

If you execute conda deactivate to switch from this environment to the (base) environment, you can see that the akshare module is not found, indicating that the base and ak_test environments are isolated.

The following two small examples show the functionality of the akshare library.

Stock strategy index curve aksharetest.py

Import akshare as akimport matplotlib.pyplot as plt

Plt.rcParams ['font.sans-serif'] =' SimHei'plt.rcParams ['axes.unicode_minus'] = False

Stock_df = ak.zdzk_fund_index (30, plot=False) futures_df = ak.zdzk_fund_index (32, plot=False)

Fig = plt.figure (111111figsize= (20,10), dpi=300) adjust_stock_df = stock_df ["20150102":] / stock_df ["20150102"] * 1000adjust_stock_df.plot (linewidth=4) adjust_futures_df = futures_df ["20150102":] / futures_df ["20150102"] * 1000adjust_futures_df.plot (linewidth=4) plt.title ("index example") plt.legend () plt.show ()

Will draw a picture.

Query aksharetest02.py for stock index

Import akshare as akstock_df = ak.stock_zh_index_spot () print (stock_df)

The following is the virtual machine file directory of vmware and the self-built environment file directory of Anaconda. Is it very similar?

At this point, the study on "installation and use of Anaconda" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report