Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'tomli' #80

Closed
mgedmin opened this issue Jan 20, 2023 · 5 comments
Closed

ModuleNotFoundError: No module named 'tomli' #80

mgedmin opened this issue Jan 20, 2023 · 5 comments

Comments

@mgedmin
Copy link

mgedmin commented Jan 20, 2023

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
@mgedmin
Copy link
Author

mgedmin commented Jan 20, 2023

~/.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?

@Orteko
Copy link

Orteko commented Feb 15, 2023

Note that I experienced the same thing on Ubuntu 22.04.1 but worked around it with an sudo apt install python3-tomli.

nedbat pushed a commit that referenced this issue Feb 18, 2023
#80

Like this:

```
$ 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'
```
nedbat pushed a commit that referenced this issue Feb 18, 2023
#80

Like this:

```
$ 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'
```
@nedbat
Copy link
Owner

nedbat commented Feb 18, 2023

Oops, sorry about that! This is fixed in 985e72b.

@nedbat nedbat closed this as completed Feb 18, 2023
@mgedmin
Copy link
Author

mgedmin commented Feb 18, 2023

I have to say I stared at the offending code for five minutes until I finally understood where the problem was!

@nedbat
Copy link
Owner

nedbat commented Feb 19, 2023

Me too!

This is now released as part of scriv 1.2.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants