question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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]`

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
arkryoniacommented, Sep 15, 2021

Hey all.

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

Thanks

1reaction
Kludexcommented, Sep 15, 2021

Glad it worked! @arkryonia

Thanks for closing the issue! 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - import "dotenv" could not be resolved - Stack Overflow
I tried to import it into my code like so: first i installed the python-dotenv library by typing pip install python-dotenv in the...
Read more >
ImportError: No module named dotenv(when I run in python3 ...
pip install -U python-dotenv. run this code for fix error. Unfortunately, this does not fix the issue. I actually think it's a virtual ......
Read more >
python-dotenv - PyPI
Getting Started. pip install python-dotenv. If your application takes its configuration from environment variables, like a 12-factor application, launching it ...
Read more >
no module named 'dotenv' - You.com | The AI Search Engine ...
To solve the error, install the module by running the pip install python-dotenv command. Open your terminal in your project's root directory and...
Read more >
ModuleNotFoundError: No module named 'dotenv' - Finxter
Solution Idea 1: Install Library dotenv​​ Before being able to import the dotenv module, you need to install it using Python's package manager...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found