The error means your WSGI server found a Python module but could not obtain the object named in its target, or that module failed while it was still initializing. Make the target match the exported Flask instance or factory, then check circular imports, package paths, and startup code. For example, gunicorn myapp:app requires an app object in myapp.py, while gunicorn 'myapp:create_app()' requires a callable factory named create_app.
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
What Flask WSGI ImportError: cannot import name app actually means
A WSGI server imports your application instead of running a development command. The target has two parts: a Python module and an exported name, written as module:object. In gunicorn package.wsgi:app, Gunicorn imports package.wsgi, then looks for an attribute called app. If that attribute is absent, or if an exception interrupts module execution before the assignment, Python raises an import error such as ImportError: cannot import name app.
As an Amazon Associate I earn from qualifying purchases.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
This differs from ModuleNotFoundError. A module-not-found error means Python could not locate the module at all. Cannot-import-name usually means the module was located but exported a different name, imported itself indirectly, or crashed during initialization. Read the first failure in the traceback; later lines often describe the same problem from another layer.
Match the WSGI target to the object your code exports
Start by opening the module named before the colon and identify the actual Flask object or factory. Do not infer the object name from the filename. A file named wsgi.py can export application, and a package can export a factory instead of a global instance.
#1 Best Overall
- BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
- EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
- COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
- LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
- WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.
| Code structure | Correct target | What the loader expects |
|---|---|---|
myapp.py contains app = Flask(__name__) |
myapp:app |
An object named app |
myapp.py contains application = Flask(__name__) |
myapp:application |
An object named application |
myapp/__init__.py contains def create_app(): |
myapp:create_app() |
A factory call that returns a Flask app |
wsgi.py contains application = create_app() |
wsgi:application |
The shim’s exported object |
Flask’s documented discovery names include app, application, create_app, and make_app. If your instance has another name, such as web_app, specify it explicitly: gunicorn myapp:web_app. A target ending in () calls a factory; omit the parentheses for an already-created application object.
Verify a minimal direct-instance application
For a small project, put the Flask instance in a module that can be imported without starting a server.
from flask import Flask
app = Flask(__name__)
@app.get('/')
def index():
return 'OK'
if __name__ == '__main__':
app.run(debug=True)
Save this as myapp.py. The matching commands are:
gunicorn myapp:app
flask --app myapp run
When you run the command from the directory containing myapp.py, the import should complete and the server should start. If you named the file app.py or wsgi.py, Flask can discover that conventional filename when the --app option is omitted. Explicit targets are still clearer in deployment configuration because they document exactly what is imported.
Never name your own module flask.py. Python may load that file when your code asks for from flask import Flask, creating a collision with the Flask package and producing confusing import failures.
Use an application factory when configuration or testing needs it
A factory creates and configures an app each time it is called. This keeps test configurations separate, supports multiple instances, and reduces import-time side effects.
Rank #2
- WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
- AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
- PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
- ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
- COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
from flask import Flask
def create_app():
app = Flask(__name__)
app.config.from_mapping(SECRET_KEY='change-me')
from .views import bp
app.register_blueprint(bp)
return app
Place this in myapp/__init__.py. A deployment target that calls the factory is:
gunicorn 'myapp:create_app()'
flask --app 'myapp:create_app()' run
Quoting the target keeps shell characters such as parentheses from being interpreted by the shell. Flask’s CLI accepts a dotted module path followed by an optional variable or factory expression. The factory must return the Flask object; returning None or a configuration object causes a different startup failure.
Factory imports should occur in an order that leaves the app available before routes are registered. Importing .views inside create_app, after the instance exists, is a practical way to avoid a route module importing the package while the package is still being initialized.
Add an explicit wsgi.py shim when a platform expects it
Some hosting configurations conventionally look for wsgi.py. The file can provide a stable export while your project keeps its real setup elsewhere.
from myapp import create_app
application = create_app()
Point the server at wsgi:application. If you instead write app = create_app(), the target must be wsgi:app. The filename alone does not determine the exported variable. A shim is also useful when several deployment systems need the same import path, but it adds one more module whose imports must remain safe.
Rank #3
- Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
- Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
- Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
- ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
- Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)
Break circular imports and partially initialized modules
The phrase partially initialized module identifies a circular import. A typical cycle looks like this:
myapp/__init__.pystarts creating the app and importsviews.py.views.pyimportsappfrommyapp.myapphas not finished assigning or configuringapp, so Python exposes an incomplete module.- The requested name cannot be imported, and the WSGI loader reports the failure.
Create the application before importing modules that use it, and avoid importing the global instance into every component. With the factory pattern, register blueprints after the app is constructed:
def create_app():
app = Flask(__name__)
from .views import bp
app.register_blueprint(bp)
return app
In request-handling code, use Flask’s current_app proxy instead of importing the app object:
from flask import Blueprint, current_app
bp = Blueprint('main', __name__)
@bp.get('/config-value')
def config_value():
return current_app.config.get('MY_SETTING', 'unset')
current_app works only while an application context is active, such as during a request or inside with app.app_context():. Code that runs at module import time has no context, so move that work into a request function, a CLI command, or an explicit initialization step.
Free tools Windows power users keep installed
One-click scans. No signup required.
Check the package path, working directory, and environment
A correct target still fails if the process runs from the wrong directory or interpreter. Test the import with the same Python environment and working directory used by Gunicorn or your host.
Rank #4
- Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
- Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
- 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
- Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
- USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC
- Change to the project directory that contains the package or module.
- Activate the virtual environment used for deployment.
- Run
python -c "import myapp; print(myapp.__file__)"to confirm which copy Python loads. - For a direct instance, run
python -c "from myapp import app; print(app)". - For a factory, run
python -c "from myapp import create_app; print(create_app())".
If the first command prints a path outside your project, an older installed package or another directory is shadowing your code. Use the fully qualified package name, install your project into the active environment, or correct the process manager’s working directory and PYTHONPATH. A package directory should contain the expected __init__.py when your packaging layout requires it, and the deployment user must be able to read every imported module.
Relative imports also depend on package context. Running a file directly as python myapp/views.py can make from .models import ... fail even though importing myapp.views works. Start the application through its package target instead of executing an internal module.
Distinguish Flask CLI behavior from production WSGI startup
flask --app myapp run is a development workflow. Flask can discover conventional app or wsgi modules when --app is omitted, and it can detect documented instance and factory names. A production command such as gunicorn myapp:app is less magical: the process manager imports exactly the module and object in the target.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Compare the two environments when a command works locally but fails in deployment:
| Check | Local CLI | Production process |
|---|---|---|
| Current directory | Usually the directory where you run the command | Set by the service, container, or hosting platform |
| Environment variables | May be loaded by your shell or development tooling | Must be configured in the service definition |
| Python path | Often includes the current directory | Depends on the service user, install method, and working directory |
| Target resolution | Can use Flask’s discovery rules | Imports the exact module:object target |
Copy the deployment command into a shell that uses the production virtual environment. If it fails there, fix the import rather than changing worker counts or timeout settings; those options cannot repair a missing export.
Best Value
- Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
- Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
- Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
- Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
- Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.
Keep development startup out of WSGI imports
Place app.run() behind a main guard:
if __name__ == '__main__':
app.run(debug=True)
Without the guard, importing the module starts Flask’s development server during WSGI initialization. The import may block, execute twice under a reloader, or bind a port before the production server is ready. A WSGI server expects the module import to finish and then calls the Flask object for each request. Complete configuration, extension setup, and route registration before requests arrive; do not add routes after workers have begun serving.
A repeatable diagnostic sequence
- Capture the first traceback. Record the module named in the error, the requested name, and the earliest underlying exception.
- Write down the target literally. For example, separate
package.wsgifromappinpackage.wsgi:app. - Open that module. Confirm it defines the requested name at module scope, or change the target to the name it actually exports.
- Test a plain import. Use
python -cwith the deployment interpreter to expose syntax errors, missing dependencies, and side effects. - Test a factory separately. Import the function, call it, and print the returned object. This distinguishes a missing function from a failure inside factory setup.
- Inspect import order. Search for modules that import the app while the package is creating it. Move blueprint imports after creation or replace app imports with
current_app. - Verify location. Print
module.__file__and confirm the process is loading the intended checkout, not a stale installation. - Remove server startup from import time. Keep
app.run()under the main guard and move one-time setup before serving begins. - Retry the exact production command. Do not validate only with a different local command whose discovery rules hide the incorrect target.
Common symptoms and precise fixes
| Symptom | Likely cause | Fix |
|---|---|---|
cannot import name app from myapp |
The module exports another variable, or initialization stopped before app was assigned. |
Rename the variable or target the real name; then fix the earlier traceback exception. |
cannot import name app from partially initialized module |
Circular import. | Create the app first, delay blueprint imports, and use current_app inside request code. |
No module named myapp |
Wrong working directory, package path, or interpreter. | Use the fully qualified package target and correct the environment or installation. |
| The CLI starts but Gunicorn fails | Flask discovery found an object that the explicit production target does not name. | Set Gunicorn’s target to the same module and exported object used by the code. |
| Import hangs or a port is already in use | Import-time code starts app.run() or performs blocking work. |
Use the main guard and keep startup initialization finite. |
| The target imports but returns a non-callable error | A factory was not called, or it returned the wrong value. | Use module:create_app() for a factory and ensure it returns the Flask instance. |
Direct instance, factory, or wsgi.py: choosing a structure
| Approach | Best fit | Advantages | Trade-offs |
|---|---|---|---|
| Direct instance | Small applications with one configuration | Shortest setup and simplest target | Global imports can become tangled as modules grow; testing multiple configurations is less convenient |
| Application factory | Applications with tests, multiple configurations, or reusable modules | Explicit lifecycle, isolated app instances, and fewer import-time cycles | Every command must call the factory, and extensions need initialization patterns that support delayed binding |
| Explicit wsgi.py shim | Platforms that expect a conventional WSGI module | Stable deployment path and a clearly named exported callable | Adds another import layer that must remain free of circular dependencies |
There is no requirement to convert a working small application to a factory solely because an import error occurred. First make the target accurate and the imports acyclic. Adopt a factory when configuration isolation, testability, or package growth justifies it.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsProduction context: why the target matters
Flask is a WSGI application. In production, a dedicated WSGI server or hosting platform imports that application and handles requests; Flask’s built-in server is intended for local development. The deployment target therefore names an importable object rather than invoking a local flask run session.
Keep secrets and environment-specific settings outside source code, load them during app creation, and make sure every worker receives the same configuration. If setup depends on a database, filesystem, or external service, fail with a specific initialization message instead of leaving the module half-imported. A clean import followed by a clear configuration error is easier to diagnose than a generic missing-name exception.
Final verification checklist
- The module portion of the target is importable from the process working directory.
- The object portion exactly matches an exported variable or a callable factory.
- Factory targets include parentheses; instance targets do not.
- No file is shadowing the Flask package, especially a project file named
flask.py. - Blueprint and route imports occur after app creation when they would otherwise form a cycle.
- Request-time code uses
current_appinstead of importing a global app unnecessarily. app.run()is protected byif __name__ == '__main__':.- The same interpreter, working directory, environment variables, and command were tested as production uses.
- Application setup finishes before the WSGI server begins handling requests.
The Bottom Line
Fix the target first: import the module that really contains your Flask code and name the exact exported instance or factory. If that target is correct, the remaining causes are usually a circular import, a wrong package path, or development-server code running during import.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




