HIVE上使用steem-python的一些尝试 (上)

in #cn4 years ago

因为我的一些脚本是用steem-python写的,所以让这些脚本已最简单的方式迁移到HIVE上,就是把steem-python库弄到HIVE上来。

image.png
(图源 :pixabay)

我看@pharesim 已经对这个库进行了迁移,所以首先打算直接用这个hive-python

尝试安装 hivepy 失败

hive-python github地址为:
https://github.com/pharesim/hive-python

按着github上的说明,首先尝试直接用pip安装:

pip install hivepy

出现N多类似如下错误:

src/scrypt.c:28:10: fatal error: Python.h: No such file or directory
#include <Python.h>
^~~~~~~~~~
compilation terminated.

应该是没装python支持的缘故,装上:

sudo apt-get install python3-dev

重新执行pip install hivepy,又出现N多类似如下错误:

scrypt-1.2.1/libcperciva/crypto/crypto_aes.c:6:10: fatal error: openssl/aes.h: No such file or directory
#include <openssl/aes.h>
^~~~~~~~~~~~~~~
compilation terminated.

应该是没装openssl支持的缘故,装上:

sudo apt install libssl-dev

貌似安装成功了,运行一下命令行:

hivepy

擦,这是什么鬼,为啥提示找不到hive呢?
image.png

试试这个:

pip install hive

我感觉有些方,这些东西都是我不认识的啊:

Reveal spoiler

image.png

装完之后再次执行:

hivepy

难道我误打误撞成功了?心里有点没有底。

Reveal spoiler

image.png

执行一下这个命令:

hivepy info

果然出错了:

Reveal spoiler

image.png

再试试代码方式安装,错误依旧:

git clone https://github.com/pharesim/hive-python.git
cd hive-python
python3 setup.py install # python setup.py install for 2.7

找到一个人家的hive库,https://pypi.org/project/hive/,不知道是干啥的,不过看看人家最后更新日期:Released: Jul 26, 2011,可用判断此hive非彼hive,我用pip install hive铁定不对了。

image.png
(图源 :pixabay)

看来用hivepy我试搞不定了,本来想找人求救,但是大家都很忙,还是我自己探索吧,还好后来终于使用steem-python搞定,我在下一篇文章中总结吧。

相关链接

Sort:  

這混亂時刻就是OO 左支右絀 大顯身手的時刻啊~~~

请教O哥,在使用steempy/beem的时候能直接指定节点,而不是使用默认节点吗?

steempy set nodes https://xxxxx

我问题没问清楚,我说的不是在命令行更改默认的节点,而是在Python程序中指定,这样就可以指添加一句话指定hive的节点,来运行之前在Steem上运行的程序了。

我又试了一下,能够正常运行hivepy了:https://hive.blog/cn/@aafeng/hive-hivepy

这样:

node = 'https://anyx.io'
hive=Hive(nodes=node)

举个查询账户余额的例子:

from hive.account import Account
from hive import Hive


node = 'https://anyx.io'
hive=Hive(nodes=node)
acc=Account("fishaa",hived_instance=hive)
banner=acc.get_balances()
print(banner)

抱歉,以为你是问hivepy,beem是这样:

from beem.steem import Steem
from beem.account import Account

nodes = 'https://api.steemit.com'
s=Steem(node=nodes)
acc = Account(player,steem_instance=s)

谢谢啦

人品问题,我用pip3 install hivepy一次成功

可能是刚更新过