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

ImportError: python-dotenv is not installed, run pip install pydantic[dotenv] #50

Closed
arkryonia opened this issue Sep 8, 2021 · 7 comments

Comments

@arkryonia
Copy link

Hey.

I'm having an weird issue with manage-fastapi. I installed all the needed packages using poetry:

pyprocject.toml file

[tool.poetry]
name = "ossah"
version = "0.1.0"
description = ""

[tool.poetry.dependencies]
python = "^3.7"
fastapi = "^0.68.1"
pydantic = {extras = ["dotenv"], version = "^1.8.2"}

[tool.poetry.dev-dependencies]
pytest = "^5.2"
pytest-cov = "^2.10.1"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

After the command fastapi run I got this error message:

  module = importlib.import_module(module_str)
  File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "./app/main.py", line 4, in <module>
    from app.core.config import settings
  File "./app/core/config.py", line 43, in <module>
    settings = Settings()
  File "pydantic/env_settings.py", line 37, in pydantic.env_settings.BaseSettings.__init__
  File "pydantic/env_settings.py", line 63, in pydantic.env_settings.BaseSettings._build_values
  File "pydantic/env_settings.py", line 154, in pydantic.env_settings.EnvSettingsSource.__call__
  File "pydantic/env_settings.py", line 227, in pydantic.env_settings.read_env_file
ImportError: python-dotenv is not installed, run `pip install pydantic[dotenv]`

@ycd
Copy link
Owner

ycd commented Sep 8, 2021

AFAICT dotenv is included in the pyproject.toml alongside with pydantic, could this be a poetry issue?

@Kludex
Copy link
Collaborator

Kludex commented Sep 9, 2021

@arkryonia Can you run:

poetry shell
poetry install

And check if you have the issue?

It should be an environment issue.

@arkryonia
Copy link
Author

AFAICT dotenv is included in the pyproject.toml alongside with pydantic, could this be a poetry issue?

Unfortunetly change poetry with pip gave the same issue. Before opening this issue, I checked it.

@arkryonia
Copy link
Author

@arkryonia Can you run:

poetry shell
poetry install

And check if you have the issue?

It should be an environment issue.

It was the basic things I did. And I did it again without success.

@arkryonia
Copy link
Author

arkryonia commented Sep 9, 2021

@arkryonia Can you run:

poetry shell
poetry install

And check if you have the issue?
It should be an environment issue.

It was the basic things I did. And I did it again without success.

@ycd @Kludex @nijat @aliereno

I decided to send my screen captures. So all doubt will be raised.

Screen Capture 1

Screen Capture 2

Voilà!

@arkryonia
Copy link
Author

Hey all.

I fix the issue by installing python-dotenv using apt get install on my Debian.

Thanks

@Kludex
Copy link
Collaborator

Kludex commented Sep 15, 2021

Glad it worked! @arkryonia

Thanks for closing the issue! 😄

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