I was chatting to @kryptik and he needed help getting setup for python development in Steem. I figured this information would be useful to others, so here it is.
This article assumes you're running on Linux. If you're running on another platform, the commands to install applications will be different; however, anything run in python should work the same.
Install dependencies
The library we'll be using to talk to Steem has some dependencies. We'll also setup a virtual environment to isolate python from the system.
sudo apt-get install libssl-dev python3-dev python3-venv
Setup the virtual environment
A virtual environment isolates python libraries from the system. This is useful if you create multiple projects that depend on different versions.
mkdir -p ~/projects/myproject
cd ~/projects/myproject
python3 -m venv venv
This command sets up a virtual environment in the folder ~/projects/myprojects/venv
. To activate the virtual environment run:
source venv/bin/activate
First we need to install the wheel library:
pip install wheel
Now we can install piston-lib, the python steem library created by @xeroc:
pip install piston-lib
Test it works
To test that the environment is setup correctly we'll run the following simple script that outputs new posts:
from piston import Steem
steem = Steem()
for c in steem.stream_comments():
# ignore comments
if c.is_comment():
continue
print("{} by {}".format(c.title, c.author))
Save the above script to the file ~/projects/myproject/myproject.py
and run it with:
python3 myproject.py
If everything is working you'll start seeing a list of posts showing the title and author.