bitcalm avatar

How to setup a python development environment for Steem

bitcalm

Published: 08 Jul 2017 › Updated: 08 Jul 2017How to setup a python development environment for Steem

How to setup a python development environment for Steem

I was chatting to kryptik@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@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.

Leave How to setup a python development environment for Steem to:

Written by

Read more #programming posts


Best Posts From bitcalm

We have not curated any of bitcalm's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From bitcalm