steem-python 学习笔记 (1)——安装steem依赖库

in #cn6 years ago (edited)

最近因为玩primas,硬是被逼上了程序员之路。

经过国庆7天的学习,从0.1开始对python有了初步的了解。为什么不是从0开始?因为我之前学了一下,学了两天因为安装steem依赖库失败放弃了。

经过学习,我写了一个初级的自动primas评论转发机器人。

但是我最爱的依然是steem。

所以,重新开始学习steem-python !


第一步,安装steem依赖库

说起这个依赖库,我可是非常的恐惧,早在几个月之前,我就想要安装这个了。

但是那时候对python一点儿也不懂,安装过程中遇到了无数挫折。

后来因为安装这个失败,直接打击我学习python的信心。

不过我现在稍微有点基础了,重新学习吧!

首先翻开@rivalhw的教程
https://steemit.com/steem-python/@rivalhw/steem-python

依次安装:

嘿,怎么我安装又出错了!

看错误信息:

error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

Microsoft Visual C++ 14.0没有安装导致的错误?
这个Microsoft Visual C++ 14.0的程序老大了,我可不想去安装这个玩意儿。

而且我有过失败的经验,安装了这个东西后还是会出错的。我才不相信呢。

继续看错误信息,是安装一个叫scrypt的依赖库错误了。

那就手动安装这个依赖库先吧。

pip install scrypt

果然报错了,果然是没那么简单。这次说什么pyhamcrest依赖库没安装。

好吧,头疼治头,脚疼治脚。

pip install pyhamcrest

什么?又说我pip版本太低?

升级pip

pip install pyhamcrest

安装成功!继续安装scrypt

pip install scrypt

安装成功…嘿嘿,感觉快成功了。

pip install steem

我去!又报错:Failed building wheel for ujson

继续头疼治头,脚疼治脚。

pip install wheel

恩,还是报错Failed building wheel for ujson

google查资料去…………

答案是:
出现原因:缺失相应的whl文件。
解决办法:下载并安装对应的whl文件。

下载这个ujson.whl文件去
下载地址

根据自己python版本来下载,我是3.7的,下载最后一个。

使用pip install “文件路径+whl文件名”即可成功安装对应的whl文件。

pip install D:\ujson-1.35-cp37-cp37m-win_amd64.whl

好了,安装成功。

pip install wheel

成功!

pip install steem

紧张等待中……………………

咦,居然成功了?不太敢相信,写条代码测试测试。

from steem import Steem
from steem.post import Post

nodes = [
'https://api.steemit.com',
'https://steemd.pevo.science',
]

s1 = Steem(nodes)

print(s1.get_account_history('maiyude', -1, 1))

返回信息

[[50013, {'trx_id': 'e660549393987df616e1897f9e6f1b63a0d1f080', 'block': 26643421, 'trx_in_block': 18, 'op_in_trx': 0, 'virtual_op': 0, 'timestamp': '2018-10-09T01:35:18', 'op': ['vote', {'voter': 'maiyude', 'author': 'statsexpert', 'permlink': 'daily-top-posts-in-category-blog-on-2018-10-09', 'weight': 500}]}], [50014, {'trx_id': '0000000000000000000000000000000000000000', 'block': 26643478, 'trx_in_block': 4294967295, 'op_in_trx': 0, 'virtual_op': 28, 'timestamp': '2018-10-09T01:38:12', 'op': ['curation_reward', {'curator': 'maiyude', 'reward': '4.038627 VESTS', 'comment_author': 'angelina6688', 'comment_permlink': 'portrait-photographymy-son-xtqs6kyu'}]}]]

有信息返回就是安装成功并且连接上了,就不管这是什么信息了。

安装成功,撒花撒花!!

总结

步骤:
1.安装Anaconda
2.pip install steem
遇到错误:
升级pip版本和安装ujson应该可以解决上述所有问题,下次遇到相同情况的同学先试试这个两个。

Sort:  

估计是执行环境的问题。

windows安装问题多多,有条件还是linux装吧。

这种编译类的都是首选linux

不太习惯linux安装软件的方式,感觉好麻烦……

补充:
如果scrypt安装不上,尝试以下办法
Users of the Anaconda Python distribution can directly obtain pre-built Windows, Intel Linux or macOS / OSX binaries from the conda-forge channel. This can be done via:

$ conda install -c conda-forge scrypt

好专业!

Posted using Partiko Android

写那么多,别人也就一行代码
pip install steem

不知道为什么我的错误特别多

刘美女有那有系列教程,你快去看呀~(目前断更了~等你看完我们一起去催更好不好~)

名字是什么?我搜索一下

https://steemit.com/da-learnpythonwithsteem/@deanliu/da-series-learn-python-with-steem-13-steem-diy-5

先隨意找給你一個連接,你在他blog下找找吧,partiko的搜索有點問題,我明天PC上找給你!

Posted using Partiko Android

发现标签对于很旧的文章没有效果,steemit的搜索也是非常不给力呀,没有用过busy不知道这方面busy是否有优化,但是steempeak对于标签也很匮乏~
最终我找了这些给你~
https://steemit.com/blog/@yjcps/learnpythonwithsteem1011-v4jp26mcli
这个是助教最后一篇课外练习内容,统计了之前刘美女0-11的课程链接在尾部,还有助教所有的课外练习~
刘美女的12和13课链接:
https://steempeak.com/da-learnpythonwithsteem/@deanliu/da-series-learn-python-with-steem-12-steem-diy-4
https://steempeak.com/da-learnpythonwithsteem/@deanliu/da-series-learn-python-with-steem-13-steem-diy-5

我突然很想去研究标签的搜索问题~还有就是在帮你找链接的时候我发现了某个数值的错误,我需要去研究下~

非常感谢,送你满赞一个

非常感谢,我也不知道为什么标签不好用,还好当时助教有统计,你学完了准备做什么?

明天我开始写《steem指南》高级篇关于机器人那章,打算写个点赞机器人示例。

你干了一件了不起的事情
好多人在windows下都没装成功😀

多年失败经验!

YOU JUST GOT UPVOTED

Congratulations,
you just received a 14.46% upvote from @steemhq - Community Bot!

Wanna join and receive free upvotes yourself?
Vote for steemhq.witness on Steemit or directly on SteemConnect and join the Community Witness.

This service was brought to you by SteemHQ.com

Hi @maiyude!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your UA account score is currently 3.412 which ranks you at #6799 across all Steem accounts.
Your rank has improved 32 places in the last three days (old rank 6831).

In our last Algorithmic Curation Round, consisting of 224 contributions, your post is ranked at #3. Congratulations!

Evaluation of your UA score:
  • You're on the right track, try to gather more followers.
  • The readers appreciate your great work!
  • Good user engagement!

Feel free to join our @steem-ua Discord server

补充全过程:
1,安装Anaconda3
2,输入 pip install steem(大多数报错)
3,pip install scrypt(安装不上用这个$ conda install -c conda-forge scrypt)
4,pip install wheel
5,pip install ujson,报错的话需要手动下载安装(https://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml)
6,再次尝试pip install steem(没啥意外应该可以安装了)

注:以上全部过程请在Anaconda3命令行下进行

Coin Marketplace

STEEM 0.32
TRX 0.11
JST 0.034
BTC 66004.40
ETH 3243.40
USDT 1.00
SBD 4.19