1. 程式人生 > >Tushare開源資料介面的安裝指南

Tushare開源資料介面的安裝指南

引言: Tushare是業界非常有名的開源資料介面,本文將簡要介紹如何安裝並使用之。

1.  官網主頁

   TuShare是一個免費、開源的python財經資料介面包; 摘自官網的資訊。 http://tushare.waditu.com/

 其相容和接收了諸多資料來源的介面資料,非常贊。

2.  安裝步驟

  本人桌面環境:Ubuntu 16.04 , python 2.7.12

   >>  sudo pip install tushare

   結果爆出以下錯誤資訊:

[email protected]:~$ pip install tushare
Collecting tushare
  Downloading http://mirrors.aliyun.com/pypi/packages/da/55/6bf90bc5eebada4a0080d3f13804c4adb555427c7c1fe5bb7dabab43ffb3/tushare-0.6.3.tar.gz (87kB)
    100% |████████████████████████████████| 92kB 821kB/s 
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-pG2c5z/tushare/setup.py", line 4, in <module>
        import tushare
      File "/tmp/pip-build-pG2c5z/tushare/tushare/__init__.py", line 98, in <module>
        from tushare.trader.trader import TraderAPI
      File "/tmp/pip-build-pG2c5z/tushare/tushare/trader/trader.py", line 19, in <module>
        from astropy.units import acount
    ImportError: No module named astropy.units
基於上述錯誤資訊,確認是缺少astropy.units包,那就安裝好了

 >> sudo pip install astropy

[email protected]:~$ pip install astropy
Collecting astropy
  Downloading http://mirrors.aliyun.com/pypi/packages/b1/52/9545d406dc5808a380a418f80b846b2a8e9058cb14f5e7a5a88b67b8feec/astropy-1.2.1-cp27-cp27mu-manylinux1_x86_64.whl (8.9MB)
    0% |▏                               | 51kB 1.9MB/s eta 0:00:05Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/dist-packages/pip/commands/install.py", line 335, in run
    wb.build(autobuilding=True)
  File "/usr/local/lib/python2.7/dist-packages/pip/wheel.py", line 749, in build
    self.requirement_set.prepare_files(self.finder)
  File "/usr/local/lib/python2.7/dist-packages/pip/req/req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/usr/local/lib/python2.7/dist-packages/pip/req/req_set.py", line 620, in _prepare_file
    session=self.session, hashes=hashes)
  File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 821, in unpack_url
    hashes=hashes
  File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 659, in unpack_http_url
    hashes)
  File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 882, in _download_http_url
    _download_url(resp, link, content_file, hashes)
  File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 603, in _download_url
    hashes.check_against_chunks(downloaded_chunks)
  File "/usr/local/lib/python2.7/dist-packages/pip/utils/hashes.py", line 46, in check_against_chunks
    for chunk in chunks:
  File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 571, in written_chunks
    for chunk in chunks:
  File "/usr/local/lib/python2.7/dist-packages/pip/utils/ui.py", line 139, in iter
    for x in it:
  File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 560, in resp_read
    decode_content=False):
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/response.py", line 357, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/response.py", line 324, in read
    flush_decoder = True
  File "/usr/lib/python2.7/contextlib.py", line 35, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/response.py", line 250, in _error_catcher
    raise ProtocolError('Connection broken: %r' % e, e)
ProtocolError: ("Connection broken: error(104, 'Connection reset by peer')", error(104, 'Connection reset by peer'))
 結果沒有成功,接著爆出錯誤資訊,針對錯誤資訊分析之後發現,其是Connection reset by peer. 很明顯是網路連線錯誤。正確的重試姿勢應該是重新執行一邊或者多次:
[sudo] password for bladestone: 
The directory '/home/bladestone/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/bladestone/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting astropy
  Downloading http://mirrors.aliyun.com/pypi/packages/b1/52/9545d406dc5808a380a418f80b846b2a8e9058cb14f5e7a5a88b67b8feec/astropy-1.2.1-cp27-cp27mu-manylinux1_x86_64.whl (8.9MB)
    100% |████████████████████████████████| 8.9MB 6.3MB/s 
Requirement already satisfied: numpy>=1.7.0 in /usr/lib/python2.7/dist-packages (from astropy)
Installing collected packages: astropy
Successfully installed astropy-1.2.1
 重新安裝tushare:
[email protected]:~$ sudo pip install tushare
The directory '/home/bladestone/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/bladestone/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting tushare
  Downloading http://mirrors.aliyun.com/pypi/packages/da/55/6bf90bc5eebada4a0080d3f13804c4adb555427c7c1fe5bb7dabab43ffb3/tushare-0.6.3.tar.gz (87kB)
    100% |████████████████████████████████| 92kB 937kB/s 
Installing collected packages: tushare
  Running setup.py install for tushare ... done
Successfully installed tushare-0.6.3
 tushare安裝成功了。

3. 檢視tushare的資料

 Tushare提供了多種資料來源頭,這裡我們僅僅檢視一下票房資料吧。

In [1]: import tushare as ts

In [2]: df = ts.realtime_boxoffice()

In [3]: df
Out[3]: 
   BoxOffice Irank MovieName boxPer movieDay sumBoxOffice                 time
0    4391.05     1        長城  62.42        4     51344.45  2016-12-19 21:24:36
1     961.06     2     血戰鋼鋸嶺  13.66       12     25038.84  2016-12-19 21:24:36
2     814.83     3   羅曼蒂克消亡史  11.58        4      7374.05  2016-12-19 21:24:36
3     258.72     4     你的名字。   3.68       18     54498.63  2016-12-19 21:24:36
4     170.56     5    28歲未成年   2.42       11     12197.34  2016-12-19 21:24:36
5     108.45     6        少年   1.54        4       991.12  2016-12-19 21:24:36
6      62.71     7      海洋奇緣   0.89       25     19660.88  2016-12-19 21:24:36
7      62.15     8   神奇動物在哪裡   0.88       25     58444.60  2016-12-19 21:24:36
8      58.79     9      薩利機長   0.84       11      5708.11  2016-12-19 21:24:36
9      50.72    10   我在故宮修文物   0.72        4       439.16  2016-12-19 21:24:36
10     95.50    11        其它   1.00        0         0.00  2016-12-19 21:24:36
 上述內容告知我們長城還是非常牛x的,上映四天,5.1344億元,當日票房佔比62.42%. 大大的厲害了

4. 總結

 Tushare是一個非常讚的開源專案,值得我們常常訪問。

相關推薦

Tushare開源資料介面安裝指南

引言: Tushare是業界非常有名的開源資料介面,本文將簡要介紹如何安裝並使用之。1.  官網主頁   TuShare是一個免費、開源的python財經資料介面包; 摘自官網的資訊。 http://tushare.waditu.com/ 其相容和接收了諸多資料來源的介面資料

資料求索(1):HDFS安裝指南

大資料求索(1):HDFS安裝指南 背景 HDFS是分散式檔案系統,是Hadoop的基礎,本章主要介紹如何安裝HDFS。 環境引數 centos 6.5 hadoop2.6.0-cdh5.7.0 jdk8 偽分散式安裝 一、JDK安裝

Python財經資料介面TuShare的使用

安裝TuShare 方式1:pip install tushare 方式2:訪問https://pypi.python.org/pypi/tushare/下載安裝 方式3:將原始碼下載到本地python setup.py install   升級TuShare 1、先檢視本地與線上的版本

BaoStock:一個免費、開源的python證券資料介面

如果需要獲取歷史行情資料、實時行情資料,www.baostock.com是個很好的免費、開源的Python證券資料介面包。特點:使用方便、免費免費免費,返回的絕大部分的資料格式都是pandas DataFrame型別。入門程式碼如下:import baostock as bs

Python 財經資料介面TuShare的基本使用

TuShare是一個免費、開源的python財經資料介面包。主要實現對股票等金融資料從資料採集、清洗加工 到 資料儲存的過程,能夠為金融分析人員提供快速、整潔、和多樣的便於分析的資料,為他們在資料獲取方面極大地減輕工作量,使他們更加專注於策略和模型的研究與實現上。考慮到Py

GandCrab v5.0.4勒索病毒家族軟體刪除+資料恢復(解除安裝指南

GandCrab勒索軟體 - 密碼病毒,它在2018年10月以三種不同的變種形式迴歸 GandCrab勒索病毒是一種廣泛使用的加密病毒,自2018年1月以來一直針對來自世界各地的使用者。自發布以來不到一年的時間內,惡意軟體已經出現多種攻擊性變種,包括 .GDCB,.KR

最新版大資料平臺安裝部署指南,HDP-2.6.5.0,ambari-2.6.2.0

一、伺服器環境配置 1 系統要求 名稱 地址 作業系統 root密碼 Master1 10.1.0.30 Centos 7.7   Master2 10.1.0.105 Centos 7.7   Worker1 10.

阿裏雲-雲監控插件安裝指南

wrapper local edge res agent install knowledge download x64 一、安裝方法:1、64位系統安裝方法,運行如下命令:sudo bash -c "wget -e ‘http_proxy=hzcmsproxy.aliyun

MySQLdb安裝指南

sta embedded env rom rar ubuntu下 develop set cheng 默認情況下,MySQLdb包是沒有安裝的,不信? 看到類似下面的代碼你就信了。-bash-3.2# /usr/local/python2.7.3/bin/python ge

zookeeper集群 新手安裝指南

datadir 服務器 follow 安裝 命名 star font left bsp Zookeeper集群的角色: Leader 和 follower (Observer) zk集群最好配成奇數個節點 只要集群中有半數以上節點存活,集群就能提供服務 本事例采用版本

CentOS 7.3 安裝指南

des 根據 http 修復 dir 繼續 支持 監控工具 報告 摘要: 基於 Red Hat 企業版的源代碼的最新版本的 CentOS 7 在今年的 12月發布了 CentOS Linux 7 (1611),包含了許多 bug 修復、新的包更新,比如 Samba、Squi

傻瓜式搭建私人網絡硬盤——owncloud安裝指南

ftp上傳 手工 data lan pos clean start osi 客戶 百度雲這個賤貨天天刪我資源,我已經忍無可忍了,於是想搭建一個owncloud來放我的裏番。使用owncloud不僅安全,而且還可以在線播放,離線下載,功能相當強大。 然而·&m

VMWare的共享文件的安裝指南

選擇 命令 以及 text 內核 安裝 界面 fontsize ops 引言:筆者這幾天基於CentOS 7的精簡版按照了一個虛擬機,悲催的是沒有圖形界面,但是非常需要共享文件的工作,在宿主機以及虛擬機之間實現文件共享,本文將描述如何實現此操作。 VMWare菜單按照VMW

python開源庫——h5py快速指南

數據集 rep spa 檢測 元組 但是 true hunk prompt 1. 核心概念 一個HDF5文件是一種存放兩類對象的容器:dataset和group. Dataset是類似於數組的數據集,而group是類似文件夾一樣的容器,存放dataset和其他gro

Storm 0.9安裝指南

3.4 sample configure 那種 gravity avi 版本 裝包 mes Storm 0.9.2安裝指南0 Storm0.9的亮點引用網上的描寫敘述:“Storm 0.9.0.1版本號的第一亮點是引入了netty transport。Storm網絡傳輸

ovn-kubernetes安裝指南

ash blog download name service enable -a cap 變量 Master節點的安裝 1、首先在master節點安裝ovs和ovn: #!/bin/bash sudo apt-get install openvswitch-common

CentOS 6 ElasticSearch 5.5.x 安裝指南

you 不支持 指南 文件 pri 索引 local arch echo 背景介紹 最新穩定版的ES 5.5.x版本對系統環境要求比較苛刻,如果不滿足的話,是無法正常啟動的。大家可以在ElasticSearch入門學習到如何安裝ES實例,這裏呢,主要向大家介紹如何解決ES在

MyEclipse WebSphere開發教程:WebSphere 7安裝指南(一)

develop 技術分享 thum server file enter 操作系統 更多 launchpad 【周年慶】MyEclipse個人授權 折扣低至冰點!立即開搶>> 【MyEclipse最新版下載】 一、先決條件和系統信息 想要使用WebSphere

graylog 2.3.2 日誌系統安裝指南

graylog cnop Java (>= 8)MongoDB 3.2Elasticsearch 2.Xgraylog 2.3.2IP 192.168.0.210centos 7.xIP 192.168.0.210 (單機測試) 結構:mongodb + elasticsearch + gra

Bugfree3.0.4 Linux環境安裝指南

protect bash protected 分享圖片 iptables chmod命令 nbsp blog tables 一、 安裝apache服務器 1. 檢查apache服務器是否安裝 service httpd status 2. 如提示未被識別的服務,則表