我爱编程

[原创]02-Linux下pyecharts安装

2018-08-04  本文已影响493人  Damon0626

背景

       最近各种热力图较为火热,较为有意思的文章如数据森麟的《三天破9亿!上万条评论解读<西红市首富>是否值得一看》(公众号id:shujusenlin)中根据网友的评论,对电影《西红市首富》的进行了一次分析。
  文章中对评论数、评论、城市分布等进行了热力图分布,看起来都非常的赞。正好周末,有时间对这个项目进行一次学习和了解。
  该项目需要用到pyecharts库,安装的过程中碰到了很多问题,失败了很多次,也找了很多资料,学到了很多东西。最后成功安装,记录一下,方便日后查看,也希望可以和更多的人交流学习。


安装0.1.9.4版本

       pyecharts0.1.9.4版本,如果不追求更多的功能,这个版本是完全可以用的。

方法比较简单:
1.下载pyecharts 0.1.9.4版本;
2.ubuntu终端中输入:

pip install pyecharts-0.1.9.4-py2.py3-none-any.whl

3.使用:

>>> import pyecharts
>>> pyecharts.__version__
'0.1.9.4'

安装0.5.6版本

       毕竟新版比旧版多很多功能,比如0.1.9.4版本中没有Overlap函数,抱着死磕到底的精神,我还是卸载了0.1.9.4版本。

1.卸载0.1.9.4

pip uninstall pyecharts

2.安装0.5.6

按照官网库介绍,有两种安装方法:

2.1安装方法

2.1.1.直接安装

pip install pyecharts

2.1.2.克隆github库安装

$ git clone https://github.com/pyecharts/pyecharts.git
$ cd pyecharts
$ pip install -r requirements.txt
$ python setup.py install
2.2安装过程中出现的问题

2.2.1 python setup.py install 报错

Traceback (most recent call last):
  File "setup.py", line 73, in <module>
    _setup_distribution = dist = klass(attrs)
......

2.2.2 pip install pyecharts 报错

$pip install pyecharts==0.5.6
$Collecting pyecharts==0.5.6
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f3211a24588>: Failed to establish a new connection: [Errno 101] 网络不可达',)': /packages/4b/20/389f802f29e95de41d63fa68ab72fed8c8afe8c543413a6964c0fa6fffe7/pyecharts-0.5.6-py2.py3-none-any.whl
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.

总是报错,好像是网络连接有问题,多次尝试仍然安装不上。后来发现问题所在,总是卡在这个地方:

 Downloading https://files.pythonhosted.org/packages/ea/ef/b46401e181768b3738660f5dc1f7ea0b334ed17fff685a61503d2989e77e/javascripthon-0.10.tar.gz (538kB)
    1% |▋                               | 10kB 6.7MB/s eta 0:00:01Exception:
Traceback (most recent call last):

试了好多次,上面的tar.gz包是下载完了,但是系统并没有安装。发现进度卡在:

 using cache: https://files.pythonhosted.org/packages/1c/a8/45e5f87ee326fbb48d36650ebb705691e4383529be0ab3281a8a8bffca09/pyecharts-0.5.5-py2.py3-none-any.whl (112kB)

然后进入.cache文件夹,删除了所有的缓存,重新按照上面方法安装还是不成功。

cd /.cache 
rm -r *

于是,就单独下载了javascripthon-0.10.tar.gz,
使用命令行进行安装,发现还是会卡住:

pip install javascripthon-0.10.tar.gz
processing ./javascripthon-0.10.tar.gz

2.2.3 安装其他依赖
2.2.3.1安装macropy3-1.1.0b2.tar.gz 成功安装;

$pip install macropy3-1.1.0b2.tar.gz 
$Processing ./macropy3-1.1.0b2.tar.gz
......
Successfully built macropy3
Installing collected packages: macropy3
Successfully installed macropy3-1.1.0b2

2.2.3.2重新尝试pip install javascripthon-0.10.tar.gz,发现返回了新的信息,显示安装一个名为dukpy-0.2.0-cp36-cp36m-manylinux1_x86_64.whl的文件

$ pip install javascripthon-0.10.tar.gz 
Processing ./javascripthon-0.10.tar.gz
Requirement already satisfied: setuptools in ./anaconda3/lib/python3.6/site-packages (from javascripthon==0.10) (36.5.0.post20170921)
Collecting dukpy (from javascripthon==0.10)
  Downloading https://files.pythonhosted.org/packages/c0/35/bd9622ca394e205614fbc8959cd2def6f0e13b3fc7f92ebb7cd094db9c16/dukpy-0.2.0-cp36-cp36m-manylinux1_x86_64.whl (2.0MB)
    3% |█▏                              | 71kB 2.1kB/s eta 0:15:05Exception:
Traceback (most recent call last):

2.2.3.3下载dukpy-0.2.0-cp36-cp36m-manylinux1_x86_64.whl,并安装,很顺利安装成功;

$ pip3 install dukpy-0.2.0-cp36-cp36m-manylinux1_x86_64.whl 
Processing ./dukpy-0.2.0-cp36-cp36m-manylinux1_x86_64.whl
Installing collected packages: dukpy
Successfully installed dukpy-0.2.0
2.3问题解决

2.3.1安装上面两个依赖后,重新安装javascripthon-0.10.tar.gz,安装成功;

$ pip install javascripthon-0.10.tar.gz Processing ./javascripthon-0.10.tar.gz
$Requirement already satisfied: setuptools in ./anaconda3/lib/python3.6/site-packages (from javascripthon==0.10) (36.5.0.post20170921)
Requirement already satisfied: dukpy in ./anaconda3/lib/python3.6/site-packages (from javascripthon==0.10) (0.2.0)
Requirement already satisfied: macropy3==1.1.0b2 in ./anaconda3/lib/python3.6/site-packages (from javascripthon==0.10) (1.1.0b2)
Building wheels for collected packages: javascripthon
  Running setup.py bdist_wheel for javascripthon ... done
  Stored in directory: /home/damon/.cache/pip/wheels/11/0f/92/abf76558960ea90ea9fb7205765f06d664b61d120168f5e0f5
Successfully built javascripthon
Installing collected packages: javascripthon
Successfully installed javascripthon-0.10

2.3.2重新尝试 pip install pyecharts 安装成功,至此大功告成。

Python 3.6.3 |Anaconda custom (64-bit)| (default, Oct 13 2017, 12:02:49) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyecharts import Overlap
>>>
>>> import pyecharts
>>> pyecharts.__version__
'0.5.6'

3效果测试

贵州省.jpg 主要城市评分.png 主要城市评论数.png

4安装思路

5参考文件

1.windows在python35上安装pyecharts
2.python安装pyecharts
3.Python安装pyecharts所遇问题及解决办法
4.pyecharts
5.Python安装pyecharts出错

上一篇下一篇

猜你喜欢

热点阅读