steem-python setup

in #steemdev8 years ago (edited)

While working on a project, I encountered some issues with the latest version of steem-python, the official python library for STEEM. There are proposed fixes in github, but these have not been merged yet.

So as a quick note to my future self, and maybe help someone else encountering this issue, here's a workaround:

NOTE: The latest version of steem-python requires Python 3.6 (not sure why). The latest version available in, for instance, the Ubuntu 16.04 package manager is 3.5 so you'll need to install 3.6 manually if you don't have it installed yet. Skip steps 1 and 2 if you already have a Python 3.6 virtual environment installed.

DISCLAIMER: I prefer to use pyenv, because it's easy to install and switch between multiple Python versions. It also handles the creation of virtual environments to keep your project's dependencies organised. Please adjust accordingly if you are using a different setup.

Step 1 - Install pyenv

If you're working on macOS:
  • install Homebrew if you haven't already
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • install pyenv and pyenv-virtualenv
brew update
brew install pyenv
brew install pyenv-virtualenv
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\n eval"$(pyenv virtualenv-init -)"fi' >> ~/.bash_profile
If you're working on Linux:
curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
Now, log out and back into your Terminal/Shell to set the proper environment variables and init pyenv.

Step 2 - Create your Python 3.6 virtual environment

pyenv install 3.6.4
pyenv virtualenv 3.6.4 my-steem-virtual-env

Replace my-steem-virtual-env with the name you'd like to give to your virtual environment.

Step 3 - Start your project and install dependencies

mkdir ~/my-steem-project
cd ~/my-steem-project
echo "my-steem-virtual-env" >> ./.python-version
cd && cd ./my-steem-project

You should now have activated your virtual environment using Python 3.6.4, so let's check that:

python -V

This should output Python 3.6.4
Now, make sure pip is up-to-date, upgrade setuptools (this was the first hurdle on my system) and install steem-python:

pip install --upgrade pip
pip install --upgrade setuptools
pip install steem

steem-python will install all sorts of dependencies, but one of them (toml) will probably fail. We can fix this as follows:

sed -i '.bak' 's/toml==0\.9\.3\.1/toml==0\.9\.3/' $(find $PYENV_VIRTUAL_ENV/lib/python3.6/site-packages/steem-* -name requires.txt)
pip install toml==0.9.3

Step 4 - Fix default steemd node

There's a hardcoded default node for steemd in the code that isn't available any more. We can fix that by explicitly specifying the nodes. First, for the sake of completeness, let's change this for the command line tool:

steempy set nodes https://api.steemit.com,https://steemd.minnowsupportproject.org,https://steemd.privex.io,https://steemd.pevo.science,https://rpc.steemliberator.com,https://gtg.steem.house:8090

Substitute your own if you like.

Then run steempy info to see if it is working as expected. It should give you a nice table with blockchain info.

Now, let's see if it is also working in a script:


Borat Very Nice Great Success - Imgur.jpg
© Imgur


Me and my fellow blockbrothers are a witness as @blockbrothers. If you want to support us we would appreciate your vote here. Or you could choose to set us as your proxy.

Vote for @blockbrothers via SteemConnect
Set blockbrothers as your proxy via SteemConnect

As blockbrothers, we build Steemify, a notification app for your Steemit account for iOS.
Get it Here:


Sort:  

s = Steem(nodes=nodes)
s.get_account('blockbrothers')

I can read this !

kungfu

Nice post, you have get 100 % upvote from @steemupvotebot, follow us for upvotes, updates and technology related news.
To, @bennierex

Ik snap er niks van Ben, maar desalnietemin.....stem ik op je!

haha, nou dat verwacht ik ook niet hoor! Bedankt voor de stem!

Ohhh ik denk het en jij zegt het.. snap er geen f*ck van maar ik vind je zo aardig...upvote dus😂😘

@bennierex. how to install on android?

Waww,cool

Please follow&vote me.I am already vote you.@arupkumer

Coin Marketplace

STEEM 0.04
TRX 0.32
JST 0.080
BTC 59313.08
ETH 1551.67
USDT 1.00
SBD 0.47