How to install steem-python in Windows

in #utopian-io6 years ago (edited)

This is my first contribution to @utopian-io. I am new to open-source, I hope to get better and contribute value to this great community in the future.

steem-python.png

Image Credit: steem.io & python.org

divider-red

What Will I Learn?

  • How to install steem-python on a Windows machine
  • How to set up CLI wallet
  • How to upvote a post using steem-python

Requirements

  • Windows computer preferably Windows 10

Difficulty

  • Basic

divider-red

Tutorial Contents

Why another steem-python installation tutorial?

I know that there are a number of how to install steem-python posts out there but I could not find any single tutorial which I could follow step by step and get steem-python running on my Windows machine. I think there are many more newbies like me who are facing the same issue.

Most tutorials are for Linux or using a Linux VM on a Windows machine. This is not always newbie friendly. So I decided to write down steps which can be followed by a newbie to install steem-python on a Windows machine and get it running.

divider-red

Using Anaconda

This tutorial uses the Anaconda distribution package for Python 3.6. Once all the installation steps are complete, the Python interpreter that comes with the Anaconda installation can be used with other IDEs like PyCharm as well.

Anaconda is a packaged distribution which comes with Python 3.6 and a number of pre-loaded packages needed for doing data science work in Python. I could not get the usual pip installer to install steem-python, but when I used conda which comes with the Anaconda distribution, I was able to quickly get it installed on my Windows 10 laptop.

I will now get down to the steps.

divider-red

Step 1- Install Anaconda with Python 3.6

If you already have Anaconda, you can skip this step. If you do not have Anaconda installed, download Anaconda with Python 3.6 from the below link and install it.
https://www.anaconda.com/download/

divider-red

Step 2 - Install steem-python

Once Anaconda is installed, use command prompt to run the following commands one by one. If you have previously tried using pip to install steem-python on your Windows machine, you will be surprised to find how smoothly this installation goes.

conda config --add channels conda-forge

conda install steem

divider-red

Step 3 - Set up steempy CLI wallet

CLI Wallet is the Command Line Only wallet of Steem and is needed to do many functions on the Steem blockchain.

3.1. Set nodes

There are many nodes which can be used, here I use three nodes. Please note there is no linebreak in the command.

steempy set nodes https://rpc.steemviz.com,https://rpc.buildteam.io,https://rpc.esteem.ws

divider-red

3.2. Import Steem account

If you face errors in this, go to the next section to 3.3. Fix steem-python CLI

Run the below command.

steempy importaccount svkrulze => use your account name in place of svkrulze

This triggers the below prompts:

- Account Passphrase:

Here, the master private key needs to be entered.

- Importing active key!
- Please provide a password for the new wallet
- Passphrase:

Here, a passphrase to encrypt the new wallet has to be entered. Remember this passphrase.

- Confirm Passphrase:

Retype the new passphrase.

- Importing posting key!
- Importing memo key!

This completes account import.

divider-red

3.3. Fix steem-python CLI

You may face errors similar to the below on running steempy importaccount svkrulze

Traceback (most recent call last): File "C:\Users\Souvik\Anaconda\Scripts\steempy-script.py", line 5, in <module> sys.exit(steem.cli.legacy()) File "C:\Users\Souvik\Anaconda\lib\site-packages\steem\cli.py", line 83, in legacy version=pkg_resources.require("steem")[0].version File "C:\Users\Souvik\AppData\Roaming\Python\Python36\site-packages\pkg_resources\__init__.py", line 984, in require needed = self.resolve(parse_requirements(requirements)) File "C:\Users\Souvik\AppData\Roaming\Python\Python36\site-packages\pkg_resources\__init__.py", line 875, in resolve raise VersionConflict(dist, req).with_context(dependent_req) pkg_resources.ContextualVersionConflict: (six 1.10.0 (c:\users\souvik\anaconda\lib\site-packages), Requirement.parse('six==1.11.0'), {'steem'})

cli-error.png

Image Credit: @svkrulze

This can be fixed by editing the METADATA file in your \Anaconda\Lib\site-packages\steem-0.18.103.dist-info folder. You can find the location of this steem-0.18.103.dist-info folder from the above error message.

3.3.a. Keep a backup of the METADATA file

You can just copy paste the file to create a backup.

3.3.b. Update version numbers in the METADATA file

Correct the required package version numbers. In above example, just replace
six (==1.11.0) with six 1.10.0. The current version in the METADATA file and the required version are both present in the error message.

3.3.c. Repeat the fix

The same error may be triggered by other packages as well. All such conflicts need to be resolved similarly. Save the final file and go to the 3.2. Import Steem account section.

divider-red

4. Set up wallet defaults

Use below commands to configure your CLI wallet.

steempy set default_account svkrulze => use your account name in place of svkrulze
steempy set default_vote_weight 25 => use a suitable value as default voting percentage
steempy config => use this command to see the configured wallet details

divider-red

Step 4 - Add environment variable for passphrase

  1. Open the Edit Environment Variables window. You can easily find it in the Control Panel or if you are using Windows 10, through the Search Box.
  2. Add an environment variable named UNLOCK and use your new passphrase as the variable value.

environment-var.png

Image Credit: @svkrulze

This step is needed to avoid the need of typing the passphrase each time you run a program which does a write operation in the blockchain.

divider-red

Step 5 - Run your first program to upvote

Write the following code and run it. Make sure to change the target url.

from steem import Steem
import os

def upvote(post, percent):

    steemPostingKey = os.environ.get('steemPostingKey')
    steem = Steem(wif=steemPostingKey)

    permlink = post

    try:
        steem.vote(permlink, percent)
        print("Succesfully upvoted!")
    except Exception as e:
        print(repr(e))

post = '@svkrulze/we-are-what-we-repeatedly-do-ramblings-on-life-12' # Update url
upvote(post, 25) # Update vote weight as needed

The program should run successfully and perform the upvote.

You can check it from steemd.com as shown below.

upvote-proof.png

Image Credit: @svkrulze

divider-red

If that vote really went through, I am sure you will be very happy. Let me know how happy you are in the comments section below.

success.jpg

Image Credit

divider-red

Goodies: Benefits for You (Referral Links)

Sell Votes on SmartSteem

Get Followers and Upvotes on SteemFollower

Get Free Crypto Coins

free-crypto2.jpg

Image Credit

divider-red

upvote-share-resteem

steem-engine.png

crypto-empire

Click on the banners to learn more about each community

leave-comment.png



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Your contribution cannot be approved because it is a duplicate. It is very similar to a contribution that was already accepted here.

You can contact us on Discord.
[utopian-moderator]

My post has specific details for Windows installation which is not what the other post has. The other post has details on how to get it running using Ubuntu on a VM. I agree some sections are common as some issues are common, but my post has details which are not there in the other post.

Hey @rufans, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!

Even though i do not understand this post .. i can make out that the post required a lot of hard and patience..good job keep it up....some day even i might understand it..

thanks for visiting, yes it took quite some work :)

Finally you did it. You are a true hustler bro. Keep up the good work.

haha, let's see how far I go with this :)

Congratulations @svkrulze! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of comments received

Click on any badge to view your own Board of Honor on SteemitBoard.

To support your work, I also upvoted your post!
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

Upvote this notification to help all Steemit users. Learn why here!

No module named "steem"

pip install steem

already installed. Any help?

Coin Marketplace

STEEM 0.20
TRX 0.13
JST 0.030
BTC 66631.72
ETH 3487.54
USDT 1.00
SBD 2.71