Trezorct does not work

Hi,
I used to upgrade the Trezor T firmware using trezorctl library from the comnand line. I did not upgrade long time ago and I wanted to update first the packages before do the upgrade. So, first I update the libraries following this doc
After, I wanted to check if all the process was successful but for my surprise, I got that error

Traceback (most recent call last):
  File "/home/me/.local/bin/trezorctl", line 7, in <module>
    from trezorlib.cli.trezorctl import cli
  File "/home/me/.local/lib/python3.6/site-packages/trezorlib/cli/__init__.py", line 25, in <module>
    from ..client import TrezorClient
  File "/home/me/.local/lib/python3.6/site-packages/trezorlib/client.py", line 24, in <module>
    from . import exceptions, mapping, messages, models
  File "/home/me/.local/lib/python3.6/site-packages/trezorlib/mapping.py", line 100, in <module>
    DEFAULT_MAPPING = ProtobufMapping.from_module(messages)
  File "/home/me/.local/lib/python3.6/site-packages/trezorlib/mapping.py", line 83, in from_module
    for entry in message_types:
TypeError: 'module' object is not iterable

Any ideas how can I solve this issue,
Thanks!

Which operating system? Guessing by the path, it looks like Linux?

Yes, you are right! I use ubuntu. I get that error when I run

trezorctl ping "ahoy!"

It seems your trezorctl installation got messed up somehow.

Try this:

  1. remove the currently installed version explicitly with:
    rm -r ~/.local/lib/python3.6/site-packages/trezorlib
    
  2. force reinstall with:
    pip3 install --force-reinstall trezor
    

If that doesn’t help, try to find out if there is no system version of trezorctl messing things up:

sudo apt remove python3-trezor
2 Likes

that works like a charm!
Now to understand the process, why do we need to do force-reinstall if we delete the folder, wouldn’t be enough with just a
pip3 install trezor
Thanks for your time!

A quick Google suggests it’s a way to skip the cache.

I could not find in googling any clear solution, thats why I asked here :sweat_smile:

Not every part of trezor installation lives in the folder you manually deleted. I also can’t be sure if pip will be aware that the package is gone by just deleting the directory.

--force-reinstall makes pip ignore the fact that there might still be pieces of the package, and install it anyway.

1 Like

To be clear, usually you could either (a) only do pip install --force-reinstall, or (b) the standard thing, pip uninstall && pip install.

In this case, it seemed to me that the contents of the directory got mixed up somehow between different installs. So I was not sure if pip just by itself would do everything needed to fix the problem. Hence manually deleting the directory.

1 Like

thanks @matejcik for that clear explanation, have a good day and thanks again for your time :raised_hands: :brain: