体验“在Ubuntu 16上配置Python和Steem开发环境“(二)

View this thread on: d.buzz | hive.blog | peakd.com | ecency.com
·@liuzg·
0.000 HBD
体验“在Ubuntu 16上配置Python和Steem开发环境“(二)
<center><img src="https://ipfs.busy.org/ipfs/QmQYqd91dQKfVswTApg5KFkAU7WDCnbfj5SYSeU4sSQF7S" alt="ubuntu-python-steem.png" /><br/><br/><a href="https://cn.yuxifan.com/setup-python-steem-development-environment-ubuntu16/">图源:范羽西博客</a></center>

> *六天前,我在[《体验“在Ubuntu 16上配置Python和Steem开发环境“》](https://busy.org/@liuzg/ubuntu16pythonsteem-gavm4ocp9i)一文中记录了我第一次在ubuntu配置Python和Steem开发环境。在编程方面我是一个门外汉,我的编程语言水平只停留在大学时的几次计算机课上,对linux、python更是白纸一张。因为是个门外汉,那次的体验可想而知,最后以失败告终。*
>
> *昨天晚上,我再次尝试了一次在Ubuntu 16上配置Python和Steem开发环境。虽然过程有点曲折,但是最后却成功了。*<br/><br/>***下面是我对我的操作过程的记录。***

### 对第一次失败的思考

在第一次配置过程中,最后出现的问题是找不到模块错误(ModuleNotFoundError)。出现这个问题,很可能是因为我们使用的steem开发软件包“steem-python”这个项目没有及时维护更新。

**为什么这么说?**

在github上,steem开发软件包[“steem-python”项目](https://github.com/steemit/steem-python)的更新还停留在2018年3月23日。在2018年6月,steem进行过一次硬分叉,这次的分叉很可能就是ModuleNotFoundError问题的元凶。

**怎么解决?**

我在网上搜索时,发现github上还有另一个steem开发软件包[“beem”项目](https://github.com/holgern/beem),它的更新时间是2019年4月19日。可以看出这个项目更新的非常及时,我决定用这个项目试一试。

### 具体步骤

1、配置Python和Steem开发环境

根据我之前的[帖子](https://busy.org/editor?draft=liuzg/ubuntu16pythonsteem-gavm4ocp9i),结合github上[“beem”项目](https://github.com/holgern/beem)的README文件完成Python和Steem开发环境的配置。

2、测试开发环境<br/>*(接下来的过程是按照@emrebeyler的post[《Beem Tutorials #1 - Introduction to Beem and creating a post with it》](https://steemit.com/utopian-io/@emrebeyler/beem-tutorials-1-introduction-to-beem-and-creating-a-post-with-it)完成。)*

a、打开shell进入虚拟运行环境
![2019-05-29 10-43-46屏幕截图.png](https://cdn.steemitimages.com/DQmSCu3jwzCdUoc7rXCTayy71x2UNFpRkCCM6N1qdB63n8c/2019-05-29%2010-43-46%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE.png)

b、打开python
![2019-05-29 10-46-02屏幕截图.png](https://cdn.steemitimages.com/DQmTHmLXXhkWEWHkdWnS3bQtwmCJ2ecHudhGkMzeKZUytTg/2019-05-29%2010-46-02%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE.png)

c、测试steem链的版本
```python
from beem import Steem
s = Steem()

print(s.get_blockchain_version())
```
![2019-05-29 10-46-24屏幕截图.png](https://cdn.steemitimages.com/DQmYHjBEiFm2JmfhLV3AQrYEP9uJzz3JvL7eqX6aMP9pcBL/2019-05-29%2010-46-24%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE.png)

当我执行到```s = Steem()```的时候,第一个错误出现(如上图)。

出现这个问题以后,我在网上没有找到答案,我猜想这个错误可能与api.steemit.com在国内被屏蔽有关。于是进入下一步:设置节点。

d、设置节点(Setting a node)
```python
from beem import Steem
s = Steem(
    node=["https://api.steemit.com",]
)
```
![2019-05-29 10-58-54屏幕截图.png](https://cdn.steemitimages.com/DQmdk4ABGhj57ZFKKFE6xrHfA4Nc3dpLu6DXwZzj8snDyMM/2019-05-29%2010-58-54%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE.png)
同样出现问题,原因还是出在api.steemit.com节点。最后我把steemit节点换成国内可用的anyx.io,执行``` s = Steem(node=["https://anyx.io",])```问题解决。

执行上一步中测试steem区块链版本号```print(s.get_blockchain_version())```,显示当前版本为:```0.20.10```。
![2019-05-29 11-11-16屏幕截图.png](https://cdn.steemitimages.com/DQmY1nN4ESAu6tomidbPk7WV2JZFaRjNZXpGRJYQCgkRRu5/2019-05-29%2011-11-16%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE.png)

### 到现在为止,在Ubuntu 16上配置Python和Steem开发环境顺利完成!!!

3、下面是我通过调试完成的开发环境发出的第一个测试帖子。

shell终端显示如下:
![2019-05-29 11-21-04屏幕截图.png](https://cdn.steemitimages.com/DQmNkPPWhU7c2HhA44sprjjCGVWDB32M4nQNbDR4wPQrLTT/2019-05-29%2011-21-04%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE.png)

busy.org显示如下:![2019-05-29 11-23-02屏幕截图.png](https://cdn.steemitimages.com/DQmPUoKmP8XoRGgTZoCuy2YKejxHF1CL2dtrNoZPx4f8MpU/2019-05-29%2011-23-02%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE.png)
👍 , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,