Install tushare in CentOS 7

2018-09-19  本文已影响0人  TR老于

Environment

CentOS 7

Install Anaconda3

Download package from https://www.anaconda.com/download/
./Anaconda3-5.2.0-Linux-x86_64.sh

Install tushare

conda create -n env_tushare python=3.6
source activate env_tushare
(env_tushare ) $ pip install tushare --upgrade

(env_tushare ) $ source deactivate

Integrate with Jupyter notebook

conda env list
source activate env_tushare
(env_tushare ) :~user conda install ipykernel

Change jupyternotebook_config.py if haven't ( in /home/[user]/.jupyter/ )

c.NotebookApp.allow_root = True
c.NotebookApp.ip = '*'
#c.NotebookApp.certfile = u'/root/.jupyter/mycert.pem'
c.NotebookApp.port= 8098
c.NotebookApp.notebook_dir = "/home/[user]/ipython"

(env_tushare ) $ python -m ipykernel install --user --name env_tushare --display-name "conda env_tushare"

Access from web

jupyter notebook

If it is the first time to access jupter notebook, please set password as the following:
http://xxx.xxx.xxx.xxx:8098
Copy the token in the log message
In web browser access: http://xxx.xxx.xxx.xxx:8098
Add your password after input the token you copied.

Get token from tushare

Following the instruction https://tushare.pro/document/1?doc_id=39

Hello Tushare

In jupyter notebook
In the web UI menu 'New' to select 'conda env_tushare' to create a Python 3 IPython file : tushare_hello

import tushare as ts
print(ts.__version__)

ts.set_token('xxxxxxxxxxxxx')  #Please set your tokent here
pro = ts.pro_api()
df = pro.trade_cal(exchange_id='', start_date='20180101', end_date='', fields='pretrade_date', is_open='0')
print(df)

install other packages

conda install -n env_tushare matplotlib

上一篇下一篇

猜你喜欢

热点阅读