How to get steem-python working on WindowssteemCreated with Sketch.

in #utopian-io6 years ago

I have spent quite some time to figure out how to get steem-python to work on Windows. I really would like to have a means of interfacing with the blockchain from my favorite Windows platform. And that's an issue with almost any blockchain. They are all *nix focused. I have tried it a couple of weeks ago and it turned out to be not easy. I gave up and searched for another solution. I ended up fooling around in C# and got some things working but then the jussi announcement came which got me doubting again. Making a library can be interesting and fun but I don't want to start over if the blockchain team changes their mind. So I gave steem-python another try. This time being more persistent. It turned out not to be easy at all. Python is cross platform, so it should be easy, but then there are the dependencies and the python version to complicate things. I have been messing around a lot, making mistakes and doing things that probably did not matter. I will try to give you as much info of which I think is relevant but I might have forgotten something.

Development setup

The workstation I used is a 64bit Windows 8.1 machine with the latest Visual Studio 2017 installed. This machine is set up for C# and C++ development. These are the workloads I think are important for steem-python.

The C++ workload. I think only the VC++ 2017 is necessary. I'm not sure though. I use this workload for daily development and did not change anything.
c++workload.png

The python workload which I added. The native development tools are important.
Pythonworkload.png

Building scrypt

When trying to install steem-python the first issue I encountered was that the scrypt dependency did not build. Failing with this error:
ScryptError.PNG
The issue is that the setup tries to build scrypt but not all files are included in the setup. The workaround is to download the sources and build it ourselves. For this you first need to install Win32 OpenSSL. I chose the "Win64 OpenSSL v1.0.2L" version. The 1.1.0 version did not work if I recall correctly. Once that is installed download the source code here

Before we can actually build the sourcecode we need to make some changes for the 64 bit platform. Open setup.py and fix the include and library directories for openssl.

setuppy.PNG

Then I could continue and build scrypt using the "x86_x64 Cross-Tools Command Prompt for VS 2017"

commandprompt.png

BuildScrypt.png

The last step is to install it using this command:
python setup.py install

Pycrypto

The next issue I was having is to install pycrypto. The issue here is an incorrect reference to stdint.h. To get this one to build I again built from the "x86_x64 Cross-Tools Command Prompt for VS 2017"

First we need to set the stdint.h as an environment variable and then we can build and install it:
python setup.py build
python setup.py install
This is an incomplete screenshot, the build step is missing but it has the correct line to set the path variable.
pycryptocmd.png

Setuptools

Steem-python still refused to install. Another thing I had to do is install the setuptools because the python setup makes use of them. I chose the latest one:
SetupTools.png

Once I got that out of the way the installation succeeded.

winrandom

The installation was now successful. Up to the fun part: try the first code. But no victory yet:

>>> from steem import Steem
File "c:\Program Files\Python35\lib\site-packages\Crypto\Random\OSRNG\nt.py", line 28, in 
<module>
import winrandom
ImportError: No module named 'winrandom'

Luckilly this was an easy one with a clear hint. I opened the file and changed import winrandom to from . import winrandom.

Finally success

Success.PNG
This certainly wasn't easy and cost me quite some time. I tried to be as complete as possible. I tried a lot of different things and I hope I did not forget something. I hope that these tips can help you in your own quest.



Open Source Contribution posted via Utopian.io

Sort:  

Yes fantastic, but completely crazy....

It should be easy and straightforward to be able to do this kind of thing....

This is a well-done tutorial and very interesting for sure. I've never had a desire to use Python on my computer, but now if I do need it, I can reference this guide! Thanks for sharing.

Not a lot of experience myself but I think the only sensible way to interface the steem blockchain.
Not fond of js.

Calling @originalworks :)
img credz: pixabay.com
Nice, you got a 50.0% @peaceandlove upgoat, thanks to @jefpatat
Want a boost? Minnowbooster's got your back!

The @OriginalWorks bot has determined this post by @jefpatat to be original material and upvoted(1.5%) it!

ezgif.com-resize.gif

To call @OriginalWorks, simply reply to any post with @originalworks or !originalworks in your message!

Qurator
Your Quality Content Curator
This post has been upvoted and given the stamp of authenticity by @qurator. To join the quality content creators and receive daily upvotes click here for more info.
Qurator is proudly supported by @reggaemuffin, vote for him as a witness here.

Thanks @jefpatat. Accepted!

[utopian-moderator]

Thanks, this is helpful! I prefer Perl myself, but have some experience with Python.

Hey @jefpatat I am @utopian-io. I have just super-voted you at 46% Power!

Achievements

-Good amount of information. Thank you!
-A very informative contribution. Good job!
-Votes on this contribution are going well. Nice!
-You are having more votes than average for this category. Nice!
-You have less than 250 followers. Just gave you a gift ;)
-Seems like you contribute quite often. AMAZING!
-You have just unlocked 6 achievements. Yeah!
Up-vote this comment to grow my power and help Open Source contributions like this one.

Coin Marketplace

STEEM 0.30
TRX 0.12
JST 0.033
BTC 63935.07
ETH 3138.68
USDT 1.00
SBD 3.87