ModuleNotFoundError: No module named 'tomli'
mgedmin opened this issue · 5 comments
I'm using Python 3.10 on Ubuntu 22.10, with pipx to manage my virtual envs for tools.
Something seems to be wrong with the tomllib dependency on Python < 3.11:
$ pipx install scriv
$ scriv --help
Traceback (most recent call last):
File "/home/mg/.local/pipx/venvs/scriv/lib/python3.10/site-packages/scriv/config.py", line 13, in <module>
import tomllib
ModuleNotFoundError: No module named 'tomllib'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/mg/.local/bin/scriv", line 5, in <module>
from scriv.cli import cli
File "/home/mg/.local/pipx/venvs/scriv/lib/python3.10/site-packages/scriv/cli.py", line 9, in <module>
from .collect import collect
File "/home/mg/.local/pipx/venvs/scriv/lib/python3.10/site-packages/scriv/collect.py", line 11, in <module>
from .scriv import Scriv
File "/home/mg/.local/pipx/venvs/scriv/lib/python3.10/site-packages/scriv/scriv.py", line 13, in <module>
from .changelog import Changelog, Fragment
File "/home/mg/.local/pipx/venvs/scriv/lib/python3.10/site-packages/scriv/changelog.py", line 10, in <module>
from .config import Config
File "/home/mg/.local/pipx/venvs/scriv/lib/python3.10/site-packages/scriv/config.py", line 15, in <module>
import tomli as tomllib # type: ignore
ModuleNotFoundError: No module named 'tomli'
Full set of versions installed in the venv:
$ pipx runpip scriv list
Package Version
------------------ ---------
attrs 22.2.0
certifi 2022.12.7
charset-normalizer 3.0.1
click 8.1.3
click-log 0.4.0
idna 3.4
Jinja2 3.1.2
MarkupSafe 2.1.2
pip 22.3.1
requests 2.28.2
scriv 1.2.0
setuptools 65.7.0
urllib3 1.26.14
wheel 0.38.4
~/.local/pipx/venvs/scriv/lib/python3.10/site-packages/scriv-1.2.0.dist-info/METADATA says
Requires-Dist: tomli ; extra == 'toml'
Requires-Dist: python-version (<3.11) ; extra == 'toml'
so I think the dependencies are working as designed? except that scriv isn't supposed to use anything toml-related unless you opt it by requesting the toml extra?
Note that I experienced the same thing on Ubuntu 22.04.1 but worked around it with an sudo apt install python3-tomli
.
I have to say I stared at the offending code for five minutes until I finally understood where the problem was!
Me too!
This is now released as part of scriv 1.2.1.