我已经安装了python-dotenv但python找不到它 [英] I have installed python-dotenv but python cannot find it

查看:131
本文介绍了我已经安装了python-dotenv但python找不到它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在烧瓶项目中使用dotenv,并且还在愚蠢的测试环境中对此进行了测试.我尝试卸载并重新安装等,但是python无法找到dotenv模块.

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.

启动flask时,它会看到一些.env文件,并告诉我即使已安装dotenv,也可以在flasks系统库中看到它.

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.

当我运行代码时,出现模块未找到错误,提示无法找到dotenv.代码是

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

错误是

任何建议都将被接受.

推荐答案

可能还安装了"dotenv"软件包.

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

此外,您可能已在系统级别(虚拟环境之外)安装了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.

这篇关于我已经安装了python-dotenv但python找不到它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆