pivoshenko / poetry-plugin-dotenv

poetry-plugin-dotenv - is the plugin that automatically loads environment variables from a dotenv file into the environment before poetry commands are run
MIT License
67 stars 4 forks source link

Getting "No module named 'tomli'" with any poetry command, after adding the plugin #238

Closed nour-sb closed 2 months ago

nour-sb commented 2 months ago

Describe the bug

pip install poetry

Collecting poetry
  Downloading poetry-1.8.2-py3-none-any.whl.metadata (6.8 kB)
Requirement already satisfied: build<2.0.0,>=1.0.3 in c:\python311\lib\site-packages (from poetry) (1.2.1)
Requirement already satisfied: cachecontrol<0.15.0,>=0.14.0 in c:\python311\lib\site-packages (from cachecontrol[filecache]<0.15.0,>=0.14.0->poetry) (0.14.0)
Requirement already satisfied: cleo<3.0.0,>=2.1.0 in c:\python311\lib\site-packages (from poetry) (2.1.0)
Requirement already satisfied: crashtest<0.5.0,>=0.4.1 in c:\python311\lib\site-packages (from poetry) (0.4.1)
Requirement already satisfied: dulwich<0.22.0,>=0.21.2 in c:\python311\lib\site-packages (from poetry) (0.21.7)
Requirement already satisfied: fastjsonschema<3.0.0,>=2.18.0 in c:\python311\lib\site-packages (from poetry) (2.19.1)
Requirement already satisfied: installer<0.8.0,>=0.7.0 in c:\python311\lib\site-packages (from poetry) (0.7.0)
Requirement already satisfied: keyring<25.0.0,>=24.0.0 in c:\python311\lib\site-packages (from poetry) (24.3.1)
Requirement already satisfied: packaging>=23.1 in c:\python311\lib\site-packages (from poetry) (24.0)
Requirement already satisfied: pexpect<5.0.0,>=4.7.0 in c:\python311\lib\site-packages (from poetry) (4.9.0)
Requirement already satisfied: pkginfo<2.0.0,>=1.9.4 in c:\python311\lib\site-packages (from poetry) (1.10.0)
Requirement already satisfied: platformdirs<5,>=3.0.0 in c:\python311\lib\site-packages (from poetry) (4.2.1)
Requirement already satisfied: poetry-core==1.9.0 in c:\python311\lib\site-packages (from poetry) (1.9.0)
Requirement already satisfied: poetry-plugin-export<2.0.0,>=1.6.0 in c:\python311\lib\site-packages (from poetry) (1.7.1)
Requirement already satisfied: pyproject-hooks<2.0.0,>=1.0.0 in c:\python311\lib\site-packages (from poetry) (1.1.0)
Requirement already satisfied: requests<3.0,>=2.26 in c:\python311\lib\site-packages (from poetry) (2.31.0)
Requirement already satisfied: requests-toolbelt<2.0.0,>=1.0.0 in c:\python311\lib\site-packages (from poetry) (1.0.0)
Requirement already satisfied: shellingham<2.0,>=1.5 in c:\python311\lib\site-packages (from poetry) (1.5.4)
Requirement already satisfied: tomlkit<1.0.0,>=0.11.4 in c:\python311\lib\site-packages (from poetry) (0.12.4)
Requirement already satisfied: trove-classifiers>=2022.5.19 in c:\python311\lib\site-packages (from poetry) (2024.4.10)
Requirement already satisfied: virtualenv<21.0.0,>=20.23.0 in c:\python311\lib\site-packages (from poetry) (20.26.1)
Requirement already satisfied: colorama in c:\python311\lib\site-packages (from build<2.0.0,>=1.0.3->poetry) (0.4.6)
Requirement already satisfied: msgpack<2.0.0,>=0.5.2 in c:\python311\lib\site-packages (from cachecontrol<0.15.0,>=0.14.0->cachecontrol[filecache]<0.15.0,>=0.14.0->poetry) (1.0.8)
Requirement already satisfied: filelock>=3.8.0 in c:\python311\lib\site-packages (from cachecontrol[filecache]<0.15.0,>=0.14.0->poetry) (3.14.0)
Requirement already satisfied: rapidfuzz<4.0.0,>=3.0.0 in c:\python311\lib\site-packages (from cleo<3.0.0,>=2.1.0->poetry) (3.8.1)
Requirement already satisfied: urllib3>=1.25 in c:\python311\lib\site-packages (from dulwich<0.22.0,>=0.21.2->poetry) (2.2.1)
Requirement already satisfied: jaraco.classes in c:\python311\lib\site-packages (from keyring<25.0.0,>=24.0.0->poetry) (3.4.0)
Requirement already satisfied: importlib-metadata>=4.11.4 in c:\python311\lib\site-packages (from keyring<25.0.0,>=24.0.0->poetry) (7.1.0)
Requirement already satisfied: pywin32-ctypes>=0.2.0 in c:\python311\lib\site-packages (from keyring<25.0.0,>=24.0.0->poetry) (0.2.2)
Requirement already satisfied: ptyprocess>=0.5 in c:\python311\lib\site-packages (from pexpect<5.0.0,>=4.7.0->poetry) (0.7.0)
Requirement already satisfied: charset-normalizer<4,>=2 in c:\python311\lib\site-packages (from requests<3.0,>=2.26->poetry) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in c:\python311\lib\site-packages (from requests<3.0,>=2.26->poetry) (3.7)
Requirement already satisfied: certifi>=2017.4.17 in c:\python311\lib\site-packages (from requests<3.0,>=2.26->poetry) (2024.2.2)
Requirement already satisfied: distlib<1,>=0.3.7 in c:\python311\lib\site-packages (from virtualenv<21.0.0,>=20.23.0->poetry) (0.3.8)
Requirement already satisfied: zipp>=0.5 in c:\python311\lib\site-packages (from importlib-metadata>=4.11.4->keyring<25.0.0,>=24.0.0->poetry) (3.18.1)
Requirement already satisfied: more-itertools in c:\python311\lib\site-packages (from jaraco.classes->keyring<25.0.0,>=24.0.0->poetry) (10.2.0)
Downloading poetry-1.8.2-py3-none-any.whl (249 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 249.4/249.4 kB 666.3 kB/s eta 0:00:00
Installing collected packages: poetry
Successfully installed poetry-1.8.2

PS C:\Users\Nour> poetry self add poetry-plugin-dotenv
Using version ^1.0.1 for poetry-plugin-dotenv

Updating dependencies
Resolving dependencies... (1.9s)

Package operations: 1 install, 0 updates, 0 removals

  - Installing poetry-plugin-dotenv (1.0.1)

Writing lock file

PS C:\Users\Nour> poetry self show -t -v

  ModuleNotFoundError

  No module named 'tomli'

  at C:\Python311\Lib\site-packages\poetry_plugin_dotenv\config.py:10 in <module>
        6│ import dataclasses
        7│
        8│ from pathlib import Path
        9│
    →  10│ import tomli
       11│
       12│
       13│ CONFIG_SOURCES: dict[str, str] = {
       14│     "pyproject.toml": "tool.poetry.plugins.dotenv",

To reproduce

Expected behaviour

adding the plugin should install all the dependencies required.

PS: installing the package manually pip install tomli did the trick and poetry works now.

Screenshots

If applicable, add screenshots to help explain your problem.

System (please complete the following information):

trecloux commented 2 months ago

Hi, if it can help, I'm facing the same error with MacOS and python 3.12.3.

pivoshenko commented 2 months ago

Got it, thanks guys! I will have a look into it today/tomorrow!

nguaman commented 2 months ago

Same issue with

python3 --version Python 3.11.9

pivoshenko commented 2 months ago

Thanks guys! Just in case I believe I found what is the issue and already more-less know how to fix it.

If anyone is interested: because the plugin doesn't have any dependency apart from poetry, I decided to reuse tomli to load config from TOML as it's part of poetry's default dependencies. But I didn't know that poetry has such constraint so instead of tomli I will switch to tomlkit

Will do the update today and run the tests

pivoshenko commented 2 months ago

Sorry guys, there is some very weird thing going on with CD workflow, for some reason it doesn't detect changes and doesn't bump the version ... Will look into it tomorrow! 🐱

pivoshenko commented 2 months ago

Just in case I manually forced the release, stupidly because of a blind copy-paste error it was a "major" release so the version now is 2.1.0 If someone can verify if the issue persists in version 2.1.0, hopefully, it should be fixed now. Hah if yes then I will look into the issue with the release workflow 🙂

pivoshenko commented 2 months ago

Okay I will be closing this issue, if anyone still faces it please feel free to reopen it and ping me

trecloux commented 2 months ago

Thanks a lot @pivoshenko it's OK for me 😊

github-actions[bot] commented 2 weeks ago

This issue has been automatically locked since there has not been any recent activity after it was closed.