Answer a question

i am using dotenv in a flask project, and have also tested this in a dumbed down test environment as well. I have tried uninstalling and reinstalling etc but the dotenv module cannot be found by python.

When starting flask it sees there are some .env files and tells me to install dotenv even though it is installed and i can see it in flasks system libraries.

This is what happens at the command line.

When I run code I get a module not found error saying it can't find dotenv. The code is

import os
from dotenv import load_dotenv
from flask import Flask
from flask_sqlalchemy import SQLAlchemy

and the error is

The error message

Any advice gratefully accepted.

Answers

It's possible that you also have the "dotenv" package installed.

In your virtual environment, try:

pip uninstall dotenv
pip uninstall python-dotenv
pip install python-dotenv

Also you may have dotenv installed at the system level (outside of your virtual environment). If yes, you could try uninstalling that.

If this is not the issue then please post your code and the resultant error.

Logo

Python社区为您提供最前沿的新闻资讯和知识内容

更多推荐