Injecting Stuff into your Python Path

| programming | python | devops |

Similar to a previous post where I wrote about how to run flask tests without installing your app, another common thing that you might want to be able to do is import your app from some arbitrary script. This is especially useful when running your app with apache mod_wsgi. This module expects the app to be installed globally or at least in the python path. Unless you install the app in a traditional sense this will not be true. The solution is just to inject the path prior to running your import statement like this.

sys.path.insert(0, '/var/www/blog')
from blog import app as application
This import will actually work.

Thank you for reading! Share your thoughts with me on bluesky, mastodon, or via email.

Check out some more stuff to read down below.

Most popular posts this month

Recent Favorite Blog Posts

This is a collection of the last 8 posts that I bookmarked.

Articles from blogs I follow around the net

My last 5 books - July 2026 edition

My last 5 books - July 2026 edition This is a new feature in which I will copy and paste my recent book reviews from my books page These are the last 5 books I have read. I will update in a month or 2 when I've read 5 more. I'm Starting to Worry About this...

via O'DonnellWeb July 12, 2026

“Animating something and animating something well are two very different things.”

From Jakub Krehel, a new blog post about self constraint in the era when AI makes it easy to ignore constraints altogether. My caveat is that the post doesn’t fully come together for me – jumping from AI to animations and then back to AI the way the author...

via Unsung July 12, 2026

Generated and suppressed demand.

Eight years ago, I wrote about my theory of restoring struggling teams, which came down to four steps: A team is falling behind if each week their backlog is longer than the week before. Solve by hiring more. A team is treading water if they’re able to get...

via Irrational Exuberance July 11, 2026

Generated by openring