Twine upload TypeError: expected string or bytes-like object

I had the same problem after installing twine by apt. It seems that it installed twine for python2 and my project was python3.

So I've installed twine with pip for python3:

pip3 install twine

and used the following command:

python3 -m twine upload dist/*

Worked perfectly fine

Updating twine solved the problem for me. For this, execute the following command before doing twine upload dist/*:

python3 -m pip install --user --upgrade twine