soranosita / crops

MIT License
32 stars 6 forks source link

Error when running:bencoder has no attribute 'decode' Did you mean 'bdecode? #2

Closed Fluff663 closed 1 year ago

Fluff663 commented 2 years ago

AttributeError: module 'bencoder' has no attribute 'decode'. Did you mean: 'bdecode'?

Fluff663 commented 2 years ago

Fixed myself by modifying parser.py will make pullrequest soon

soranosita commented 2 years ago

Hi Fluff,

I saw your pull request (#3), and I'm trying to figure out why bencoder.encode and bencoder.decode give you an AttributeError. Looking at the library's source code, the methods are indeed named encode and decode. The same code is hosted on PyPI, so there should be no difference with what you have on your local machine. In fact, I'm unable to replicate this on a fresh Python 3 venv.

Are you sure you installed the correct library? Could you try running pip install --upgrade --force-reinstall bencoder?

wally-crunk commented 1 year ago

I had the same error @Fluff663 . On Mac with multiple pythons installed via pyenv, I had multiple bencoders installed. What fixed this for me was:

  # enter the command line environment
 python
  # do just as parser.py does
 >>> import bencoder
  # show where the bencoder that's being run is located
 >>> print (bencoder.__file__)
 /Users/jj/.pyenv/versions/3.11.2/lib/python3.11/site-packages/bencoder.cpython-311-darwin.so
  # quit python
 >>> [control-D]
 #  open that folder 
 jj@mac src % cd /Users/jj/.pyenv/versions/3.11.2/lib/python3.11/site-packages/                        
 jj@mac src % open .

I had several bencoders: bencoder.py, bencoder-0.2.0, bencoder-0.2.1, and bencoder.cpython-311-darwin.so. So I nuked bencoder.cpython-311-darwin.so by ZIPPING it (for a backup) and deleting the original and then.. it worked.

TLDR-- See if you have multiple bencoder modules installed too.