twine: Twine 3.8 - missing install requirement

Environment

  1. Operating system: Ubuntu 20.04

  2. Version of python: 3.8

  3. Twine installed method pip install twine

  4. Version of twine: twine-3.8.0-py3-none-any.whl

  5. Target repository for twine to upload to? pypi

The Issue

The “twine upload” command breaks with stacktrace:

 Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.8.12/x64/bin/twine", line 5, in <module>
    from twine.__main__ import main
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/twine/__main__.py", line 22, in <module>
    from twine import cli
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/twine/cli.py", line 18, in <module>
    from packaging import requirements
ModuleNotFoundError: No module named 'packaging'

Workaround

install the “packaging” package manually: pip install packaging

Proposed fix:

Add “packing” to install_requires section in https://github.com/pypa/twine/blob/main/setup.cfg

Steps to Reproduce

create a new python virtualenv without installing any packages except twine It seems that if you install tox, tox installs the missing package twine itself requires(packaging). So not installing tox in an environment and only installing twine, reproduces the error: pip install twine

twine upload --skip-existing -r pypi sample-1.0.0-py3-none-any.whl sample-1.0.0-py3-none-any.whl.asc

This command will break and indicated above.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (1 by maintainers)

Most upvoted comments

Yes, thanks @bhrutledge , the upgrade to 4.0.0 does solve the issue.

I’m happy if you want to close this issue.