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

“Insert your favorite nursery rhyme.”

Make Some Noise is one of many fantastic improv comedy shows on Dropout. I noticed one of the ongoing themes is “tech gone bad,” so I compiled a short list below. I just find these really funny. Video call with shitty wifi: Logging in with 30-factor authen...

via Unsung September 17, 2026

Why are short videos bad for learning?

An essay version of the video is below – not just a transcript but a text that I’ve rewritten thoroughly to work as text. As is an audio version. You can subscribe to the audio-only unlisted podcast feed here if audio is more your speed. Overview # In this...

via Baldur Bjarnason's Notes on the Web September 17, 2026

Why we should be very worried about the Hugging Face hack

(Note: This is a re-run of a piece I published on September 3rd. I am backwoods camping this week in the Canadian wilderness and will have no signal so please excuse me for the repeat!)About a month ago, I (and many others) wrote about an incident in which

via The Torment Nexus September 17, 2026

Generated by openring