第二章 财经数据接口包tushare 以及anaconda安装

时间:2024-05-19 13:31:51

初步学了一周的python了,大概摸索着开始学习股票的数据接口包。
边练边学,边查询资料,这样效率应该能快一些。
第二章 财经数据接口包tushare 以及anaconda安装
安装方式,因为tushare有一些前置依赖,官方推荐

建议安装Anaconda(http://www.continuum.io/downloads),一次安装包括了Python环境和全部依赖包,减少问题出现的几率。
Anaconda的官网界面挺漂亮的,选择对应的操作系统下载即可

安装的时候会有个提示:
第二章 财经数据接口包tushare 以及anaconda安装
如果之前已经单独安装过python的话,就选第一项。
第二项会让其他的IDE,工具自动关联到anaconda上。
安装完成后,会多出几个anaconda为前缀的程序。
第二章 财经数据接口包tushare 以及anaconda安装
What is Anaconda Navigator?
Anaconda Navigator is a desktop graphical user interface (GUI) included in Anaconda® distribution that allows you to launch applications and easily manage conda packages, environments and channels without using command-line commands. Navigator can search for packages on Anaconda Cloud or in a local Anaconda Repository. It is available for Windows, macOS and Linux.
前面说了,anaconda是一个集成的工具平台,它本身就集成了python3.6.4版本,和几百个扩展库,虽然能够使用命令行来管理,但不够人性化,所以后来增加了图形化的管理界面,就是 Anaconda Navigator。
第二章 财经数据接口包tushare 以及anaconda安装


Anaconda prompt就是anaconda的控制台命令行交互,它能够完成anaconda的所有功能,前面有一个(base)提示,说明工作在基础环境下。
如果输入python,就去调用自带的python3.6.4版本,此时>>>和我之前单独安装的python3.6.5版本没有本质区别。
第二章 财经数据接口包tushare 以及anaconda安装
在Anaconda prompt交互中,当然可以使用conda包管理工具进行管理:
Conda is a powerful package manager and environment manager that you use with command line commands at the Anaconda Prompt for Windows, or in a Terminal window for macOS or Linux.
第二章 财经数据接口包tushare 以及anaconda安装
conda的版本是4.4.10
1.进行环境管理:
Managing Environments

Conda allows you to to create separate environments containing files, packages and their dependencies that will not interact with other environments.

When you begin using conda, you already have a default environment named base. You don’t want to put programs into your base environment, though. Create separate environments to keep your programs isolated from each other.
使用 conda info -e 可以知道当前环境是哪个,默认是base
第二章 财经数据接口包tushare 以及anaconda安装

2.在新环境下,进行python版本管理
Managing Python

When you create a new environment, conda installs the same Python version you used when you downloaded and installed Anaconda. If you want to use a different version of Python, for example Python 3.5, simply create a new environment and specify the version of Python that you want.

3.在新环境下,进行包管理
Managing packages

个人理解:

当然,所有的功能都可以用图形化界面的方式来完成,更简单方便。
如果使用conda命令来安装第三方库,必须是anaconda预先集成好的,如果没有集成好,那就只能使用python自带的pip工具安装了,比如财经数据tushare,它就只能使用pip安装。
这样的安装方法没有使用conda,会不会造成anaconda环境无法识别,没办法进行配置管理的缺点呢?
我网络上查询了一下,发现如果使用Anaconda prompt,在这个界面下再使用pip安装,anaconda环境一样能够识别,挺智能的。
用conda list 检查一下果然有tushare
第二章 财经数据接口包tushare 以及anaconda安装
第二章 财经数据接口包tushare 以及anaconda安装


spyder就是前面说的IDE,集成开发环境。
另外anaconda官网还给出了常见集成开发环境的文档介绍:
第二章 财经数据接口包tushare 以及anaconda安装
第二章 财经数据接口包tushare 以及anaconda安装

IPython也是Jupyter notebook的核心。
第二章 财经数据接口包tushare 以及anaconda安装
第二章 财经数据接口包tushare 以及anaconda安装