How to install steem-python on Ubuntu 16.04 and get steempy working

in #utopian-io6 years ago (edited)

image.png

Ubuntu 16.04 is very popular Linux distro and probably most of fresh Linux users use it. The problem with running steem-python on Ubuntu 16.04 is that the Ubuntu comes with Python 3.5 and steem-python requires Python 3.6.

What is steem-python?

It's a swiss army knife for Steem Python developers ;-) Accordingly to GitHub description,

steem-python is the official STEEM library for Python. It comes with a BIP38 encrypted wallet and a practical CLI utility called steempy

Install Python 3.6

We'll install Python 3.6 from PPA repositories, let's add new APT source,

$ sudo add-apt-repository ppa:jonathonf/python-3.6
OK

 
if you get error about missing add-apt-repository command, please install software-properties-common package: apt-get install software-properties-common

Now you can update APT database and install Python3.6, pip and required libssl-dev packages,

$ sudo apt-get update && sudo apt-get install python3.6 python3.6-dev libssl-dev
...
...
Get:6 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial/main amd64 Packages [4,492 B]
Get:7 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial/main Translation-en [2,028 B]
Fetched 24.6 kB in 0s (43.1 kB/s)
Reading package lists... Done
...
...
The following NEW packages will be installed:
  libssl-dev python3.6 python3.6-dev
...

 
PIP for Python 3.6 doesn't exist in PPA, but we'll install it manually,

$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python3.6 get-pip.py

Install steem-python

$ sudo pip3.6 install -U steem
...
...
Successfully installed scrypt-0.8.0 steem-0.18.103 toml-0.9.3 toolz-0.8.2 ujson-1.35 voluptuous-0.10.5 w3lib-1.18.0

 
steem-python has been installed :) but there is one more issue to fix, steempy (CLI) won't work due to toml package issue...

$ steempy
...
...
Original exception was:
Traceback (most recent call last):
  File "/usr/local/bin/steempy", line 7, in <module>
    steem.cli.legacy()
  File "/usr/local/lib/python3.6/dist-packages/steem/cli.py", line 83, in legacy
    version=pkg_resources.require("steem")[0].version
  File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 984, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 875, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (toml 0.9.3 (/usr/local/lib/python3.6/dist-packages), Requirement.parse('toml==0.9.3.1'), {'steem'})

 
This is known problem and easy to fix, the steem-python requires toml==0.9.3.1 but unfortunately the creator of toml messed up the package versions, and 0.9.3.1 version is recognized as 0.9.3... let's fix it,

$ grep toml /usr/local/lib/python3.6/dist-packages/steem-0.18.103-py3.6.egg-info/requires.txt
toml==0.9.3.1

 
All what you need to do is change the line in /usr/local/lib/python3.6/dist-packages/steem-0.18.103-py3.6.egg-info/requires.txt file,

from

toml==0.9.3.1

 
to

toml==0.9.3

 
when it's done you can run steempy,

$ steempy
usage: steempy [-h] [--node NODE] [--no-broadcast] [--no-wallet] [--unsigned]
               [--expires EXPIRES] [--verbose VERBOSE] [--version]
               {set,config,info,changewalletpassphrase,addkey,parsewif,delkey,getkey,listkeys,listaccounts,upvote,downvote,transfer,powerup,powerdown,powerdownroute,convert,balance,interest,permissions,allow,disallow,newaccount,importaccount,updatememokey,approvewitness,disapprovewitness,sign,broadcast,orderbook,buy,sell,cancel,resteem,follow,unfollow,setprofile,delprofile,witnessupdate,witnesscreate}

 
it works! let's do one more check,

$ steempy info

image.png

Yeah, looks good. Now we can check the steem-python module itself,

$ python3.6
Python 3.6.3 (default, Oct  6 2017, 08:44:35)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import steem
>>> s = steem.Steem()
>>> s.get_account('jamzed')
{'id': 103323, 'name': 'jamzed', 'owner': {'weight_threshold': 1, 'account_auths': [], 'key_auths': [['STM7ss8gKeorUBd2GQ6GbgUWukevnGTWbA7UDbYAPvMDcpecKN9Ni', 1]]}, 'active': {'weight_threshold': 1, 'account_auths': [], 'key_auths': [['STM7WXHqMkvi9Lcsq7Mun2SWchjF1uC33dNGiN9HShAQqDN8JpoGH', 1]]}, 'posting': {'weight_threshold': 1, 'account_auths': [['busy.app', 1], ['utopian.app', 1]], 'key_auths': [['STM6v4Fo2uVrziELGyqmS2yd7q1eJzfhJKMqN3KmrHN8sMwTnzzz5', 1]]}, 'memo_key': 'STM6kGHddusAbGnBE4D1w8RWhNezE2mvcftggKjLWZsD63ejVQDt3', 'json_metadata': '{"profile":{"name":"Patryk Kuźmicz","about":"[ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo Click","location":"Kraków","website":"https://patryk.kuzmi.cz","profile_image":"https://i.imgur.com/NohuYO1.png"}}', 'proxy': '', 'last_owner_update': '2017-11-23T11:38:33', 'last_account_update': '2017-11-23T11:38:33', 'created': '2016-10-06T14:16:48', 'mined': False, 'owner_challenged': False, 'active_challenged': False, 'last_owner_proved': '1970-01-01T00:00:00', 'last_active_proved': '1970-01-01T00:00:00', 'recovery_account': 'steem', 'last_account_recovery': '1970-01-01T00:00:00', 'reset_account': 'null', 'comment_count': 0, 'lifetime_vote_count': 0, 'post_count': 69, 'can_vote': True, 'voting_power': 9250, 'last_vote_time': '2017-11-26T20:17:15', 'balance': '0.000 STEEM', 'savings_balance': '0.000 STEEM', 'sbd_balance': '0.171 SBD', 'sbd_seconds': '25606731', 'sbd_seconds_last_update': '2017-11-26T19:41:51', 'sbd_last_interest_payment': '2017-10-31T11:22:33', 'savings_sbd_balance': '0.000 SBD', 'savings_sbd_seconds': '0', 'savings_sbd_seconds_last_update': '1970-01-01T00:00:00', 'savings_sbd_last_interest_payment': '1970-01-01T00:00:00', 'savings_withdraw_requests': 0, 'reward_sbd_balance': '0.000 SBD', 'reward_steem_balance': '0.000 STEEM', 'reward_vesting_balance': '6.158415 VESTS', 'reward_vesting_steem': '0.003 STEEM', 'vesting_shares': '328049.905307 VESTS', 'delegated_vesting_shares': '0.000000 VESTS', 'received_vesting_shares': '0.000000 VESTS', 'vesting_withdraw_rate': '0.000000 VESTS', 'next_vesting_withdrawal': '1969-12-31T23:59:59', 'withdrawn': 0, 'to_withdraw': 0, 'withdraw_routes': 0, 'curation_rewards': 753, 'posting_rewards': 44017, 'proxied_vsf_votes': ['34134838232', 0, 0, 0], 'witnesses_voted_for': 22, 'average_bandwidth': '38261968148', 'lifetime_bandwidth': '348501000000', 'last_bandwidth_update': '2017-11-26T22:55:24', 'average_market_bandwidth': 1498648363, 'lifetime_market_bandwidth': '11610000000', 'last_market_bandwidth_update': '2017-11-26T19:41:03', 'last_post': '2017-11-26T15:35:27', 'last_root_post': '2017-11-22T12:35:57', 'vesting_balance': '0.000 STEEM', 'reputation': '337626802057', 'transfer_history': [], 'market_history': [], 'post_history': [], 'vote_history': [], 'other_history': [], 'witness_votes': ['aggroed', 'arcange', 'ausbitbank', 'busy.witness', 'clayop', 'complexring', 'drakos', 'furion', 'good-karma', 'gtg', 'jamzed', 'jesta', 'klye', 'lukestokes.mhth', 'moorkedi', 'netuoso', 'pfunk', 'pharesim', 'riverhead', 'someguy123', 'themarkymark', 'timcliff'], 'tags_usage': [], 'guest_bloggers': []}

 
Enjoy and build something big! ;-)



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for good information. Mostly works good.
I did some additional job.

  • install gcc
    apt-get install gcc
  • toml setting
    /usr/local/lib/python3.6/dist-packages/steem-0.18.103.dist-info/METADATA
  • change server
    steempy set nodes https://api.steemit.com

It work! thanks, after 3 hours trying I found your tuto. Thanks very much.

Thanks, good to hear that ;-)

can you explane me how to intall in on kali linux. i have an error when installing

Please paste the details.

This the ss , please help me
image

How did you install Python3.6? Seems it doesn't support ssl module. If you compiled it from sources, please install libssl-dev package and recompile it.

OKe thank, can i get your contact. I think some time i need to ask something to you

I’m available on steemit.chat, the same nick. ;-)

Your contribution cannot be approved because you posted using the wrong category. The right category for your contribution is "Tutorial". Please when submitting contribution in the future, Kindly choose the correct category. Thank you.
You can contact us on Discord.
[utopian-moderator]

Thanks, good to know. Is it possible to move it to "Tutorial" section?

It's impossible to do, Except you delete this one and repost in the right category.
[utopian-moderator]

This post has received a 6.86 % upvote from @buildawhale thanks to: @jamzed. Send at least 1 SBD to @buildawhale with a post link in the memo field for a portion of the next vote.

To support our daily curation initiative, please vote on my owner, @themarkymark, as a Steem Witness

Can you help ?
I am getting this error .

grep: /usr/local/lib/python3.6/dist-packages/steem-0.18.103-py3.6.egg-info/requires.txt: No such file or directory

You need to find the correct location of Steem module,
ls -la /usr/local/lib/python3.6/dist-packages/
and use updated path for further operations.

thanks that helped , done installing python !! Are you on steemitchat or discord ?

Thanks again :)

Good to hear that, I’m sitting on both ;-)

I dont have this file: /usr/local/lib/python3.6/dist-packages/steem-0.18.103-py3.6.egg-info/requires.txt file

;(

there isnt even any requires.txt in any of the folders

Update:

I just created the folder with the file and the content and I am able to call steempy.. but not steempy info

WARNING:urllib3.connectionpool:Retrying (Retry(total=19, connect=None, read=None, redirect=0, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f3283f50668>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /

Coin Marketplace

STEEM 0.36
TRX 0.12
JST 0.039
BTC 69735.97
ETH 3533.64
USDT 1.00
SBD 4.72