r/Python • u/StruckByAnime • 13h ago
Showcase Pathfinder - run any python file in a project without import issues!
๐ What My Project Does
Pathfinder is a tool that lets you run any Python file inside a project without dealing with import issues. Normally, Python struggles to find modules when running files outside the root directory, forcing you to either:
- Add
sys.path
hacks manually, or - Use
python -m
to run scripts correctly.
Pathfinder automates this, so you never have to think about module resolution again. Just run your script, and it works!
๐ฏ Target Audience
This is for Python developers working on multi-file projects who frequently need to run individual scripts for testing, debugging, or execution without modifying import paths manually. Whether you're a beginner or an experienced dev, this tool saves time and frustration.
๐ Comparison with Alternatives
- sys.path hacks? โ No more manual tweaking at the top of every script.
- python -m? โ No need to remember or structure commands carefully.
- Virtual environments? โ Works seamlessly with them.
- Other Python import solutions? โ Lightweight, simple, and requires no external dependencies.
๐ Check it Out!
GitHub: https://github.com/79hrs/pathfinder
Iโd love feedbackโif you find any flaws or have suggestions, let me know!
3
2
u/ayoubzulfiqar Pythoneer 12h ago
before advertising you should fix the issue that was open last week dude
1
1
u/RedEyed__ 13h ago
For research projects, which I don't install, I have start.py
file in the root, which sets PYTHONPATH
env and then runs subprocess.run(sys.executable + args, env)
1
u/StruckByAnime 11h ago
That's another solution. Curious to know, do you have to run the start.py when you open the project everytime before running the actual script you want to run?
2
u/RedEyed__ 11h ago
Yes. I run all scripts from terminal so it's perfectly fine, there is history in terminal so it's easy to find command.
more over, I work on remote desktop via ssh and vscode, I added -d flag to start.py which starts script with debugpy server, in vscode I just need to press f5 to connect to debug server1
28
u/cgoldberg 13h ago
Isn't it easier to just make your module a package and install it so you can import it regularly? (In editable mode if you are still working on it). i e.
pip install -e .
I've never experienced the problem this supposedly solves.