<p dir="auto">Currently, the env var in <code class="notranslate">.env</code> or <code class="notranslate">.flaskenv</code> will not override existing value. However, if a user installed <code class="notranslate">python-dotenv</code> and created a <code class="notranslate">.flaskenv</code>, he will expect the variables in <code class="notranslate">.flaskenv</code> override the old values. It's inconvenience when you develop multiple applications at the same time.</p>
<p dir="auto">I want to start by apologizing in advance if I make any mistakes in this bug report, I'm new to development and any mistakes are unintentional. That being said I appreciate any input as to how I can improve.</p>
<h1 dir="auto">The issue:</h1>
<p dir="auto">Creating a class that inherits from FlaskForm causes an error with the following traceback</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Error: While importing 'app', an ImportError was raised:

Traceback (most recent call last):
  File &quot;/home/rburd/.local/share/virtualenvs/d5-9RMvys9g/lib/python3.11/site-packages/flask/cli.py&quot;, line 218, in locate_app
    __import__(module_name)
  File &quot;/home/rburd/academy/Mod-6/w18/d5/app/__init__.py&quot;, line 2, in &lt;module&gt;
    from .form import Tweet
  File &quot;/home/rburd/academy/Mod-6/w18/d5/app/form.py&quot;, line 1, in &lt;module&gt;
    from flask_wtf import FlaskForm
  File &quot;/home/rburd/.local/share/virtualenvs/d5-9RMvys9g/lib/python3.11/site-packages/flask_wtf/__init__.py&quot;, line 4, in &lt;module&gt;
    from .recaptcha import Recaptcha
  File &quot;/home/rburd/.local/share/virtualenvs/d5-9RMvys9g/lib/python3.11/site-packages/flask_wtf/recaptcha/__init__.py&quot;, line 1, in &lt;module&gt;
    from .fields import RecaptchaField
  File &quot;/home/rburd/.local/share/virtualenvs/d5-9RMvys9g/lib/python3.11/site-packages/flask_wtf/recaptcha/fields.py&quot;, line 3, in &lt;module&gt;
    from . import widgets
  File &quot;/home/rburd/.local/share/virtualenvs/d5-9RMvys9g/lib/python3.11/site-packages/flask_wtf/recaptcha/widgets.py&quot;, line 2, in &lt;module&gt;
    from flask import Markup
ImportError: cannot import name 'Markup' from 'flask' (/home/rburd/.local/share/virtualenvs/d5-9RMvys9g/lib/python3.11/site-packages/flask/__init__.py)"><pre class="notranslate"><code class="notranslate">Error: While importing 'app', an ImportError was raised:

Traceback (most recent call last):
  File "/home/rburd/.local/share/virtualenvs/d5-9RMvys9g/lib/python3.11/site-packages/flask/cli.py", line 218, in locate_app
    __import__(module_name)
  File "/home/rburd/academy/Mod-6/w18/d5/app/__init__.py", line 2, in &lt;module&gt;
    from .form import Tweet
  File "/home/rburd/academy/Mod-6/w18/d5/app/form.py", line 1, in &lt;module&gt;
    from flask_wtf import FlaskForm
  File "/home/rburd/.local/share/virtualenvs/d5-9RMvys9g/lib/python3.11/site-packages/flask_wtf/__init__.py", line 4, in &lt;module&gt;
    from .recaptcha import Recaptcha
  File "/home/rburd/.local/share/virtualenvs/d5-9RMvys9g/lib/python3.11/site-packages/flask_wtf/recaptcha/__init__.py", line 1, in &lt;module&gt;
    from .fields import RecaptchaField
  File "/home/rburd/.local/share/virtualenvs/d5-9RMvys9g/lib/python3.11/site-packages/flask_wtf/recaptcha/fields.py", line 3, in &lt;module&gt;
    from . import widgets
  File "/home/rburd/.local/share/virtualenvs/d5-9RMvys9g/lib/python3.11/site-packages/flask_wtf/recaptcha/widgets.py", line 2, in &lt;module&gt;
    from flask import Markup
ImportError: cannot import name 'Markup' from 'flask' (/home/rburd/.local/share/virtualenvs/d5-9RMvys9g/lib/python3.11/site-packages/flask/__init__.py)
</code></pre></div>
<p dir="auto">If I switch to flask ver. 2.2.3 I receive no such error</p>
<h1 dir="auto">How to reproduce:</h1>
<p dir="auto">Start a new project in an empty directory using the command <code class="notranslate">pipenv install flask flask-wtf python-dotenv</code><br>
Create a subfolder named 'app' with the following files</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# /app/__init__.py
from flask import Flask
from .form import Tweet

app = Flask(__name__)
"><pre class="notranslate"><span class="pl-c"># /app/__init__.py</span>
<span class="pl-k">from</span> <span class="pl-s1">flask</span> <span class="pl-k">import</span> <span class="pl-v">Flask</span>
<span class="pl-k">from</span> .<span class="pl-s1">form</span> <span class="pl-k">import</span> <span class="pl-v">Tweet</span>

<span class="pl-s1">app</span> <span class="pl-c1">=</span> <span class="pl-v">Flask</span>(<span class="pl-s1">__name__</span>)</pre></div>
<p dir="auto">and</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# /app/form.py
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField

class Tweet(FlaskForm):
    author = StringField(&quot;Author&quot;)
    submit = SubmitField(&quot;Create New Tweet&quot;)"><pre class="notranslate"><span class="pl-c"># /app/form.py</span>
<span class="pl-k">from</span> <span class="pl-s1">flask_wtf</span> <span class="pl-k">import</span> <span class="pl-v">FlaskForm</span>
<span class="pl-k">from</span> <span class="pl-s1">wtforms</span> <span class="pl-k">import</span> <span class="pl-v">StringField</span>, <span class="pl-v">SubmitField</span>

<span class="pl-k">class</span> <span class="pl-v">Tweet</span>(<span class="pl-v">FlaskForm</span>):
    <span class="pl-s1">author</span> <span class="pl-c1">=</span> <span class="pl-v">StringField</span>(<span class="pl-s">"Author"</span>)
    <span class="pl-s1">submit</span> <span class="pl-c1">=</span> <span class="pl-v">SubmitField</span>(<span class="pl-s">"Create New Tweet"</span>)</pre></div>
<p dir="auto">Create a .flaskenv file with the following contents:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="FLASK_APP=app"><pre class="notranslate"><code class="notranslate">FLASK_APP=app
</code></pre></div>
<p dir="auto">Finally try to start the app with the command <code class="notranslate">pipenv run flask run</code></p>
<h1 dir="auto">What I Expected:</h1>
<p dir="auto">When the <code class="notranslate">flask run</code> command is given no error should occur, which is the behavior observed when using flask ver. 2.2.3</p>
<p dir="auto">Environment:</p>
<ul dir="auto">
<li>Python version: 3.11.3</li>
<li>Flask version: 2.3.0</li>
</ul>