Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'bytes' object has no attribute 'encode' #4

Closed
andmanousakis opened this issue May 3, 2019 · 2 comments
Closed

AttributeError: 'bytes' object has no attribute 'encode' #4

andmanousakis opened this issue May 3, 2019 · 2 comments

Comments

@andmanousakis
Copy link

I get the following error as soon as i start the script:

Start /media/aman/BTC_Blockch/blocks/blk00000.dat in 2019-05-03 17:42:56.161722
Traceback (most recent call last):
File "blockchain-parser.py", line 64, in
b = b.encode('hex').upper()
AttributeError: 'bytes' object has no attribute 'encode'

Ideas?

@qzshucsz
Copy link

It may be the version problem of python. In python3, bytes to hex string is not longer be bytes.encode('hex'). Python3 has a more convenient way, such as bytes.hex(). You can see more detail in https://stackoverflow.com/questions/6624453/whats-the-correct-way-to-convert-bytes-to-a-hex-string-in-python-3 . As for your question, you can try to replace all b=b.encode('hex').upper()
to b=b.hex().upper() if you are using python3. In addition, if you see another problem "str" object has no attribute 'decode', you can use bytes.fromhex(your_bytes).

@ragestack
Copy link
Owner

I make some changes, and now script working with Python 3.8 or higher. It seems that newer version of Python produces more fast parsing and that's why script now compatible with highest versions of Python interpreter without support of oldest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants