What’s the correct process to install and run a .py application and its dependencies? Where should I save the .py file, where should I run it from, and can it interfere with the rest of my system?
Often there is an application/script I’d like to use and it is provided as a .py file download, along with a list of other applications/scripts that need to be installed separately for it to work. Often not all of these dependencies are available in my distro’s repository. There seems to be an assumption of prior knowledge as to how to get set up to run .py files, and it is therefore not documented on developers pages. Can anyone fill me in?
I’d like to install this application. Perhaps it could be used as an example to help explain the process.
My distro is Debian 13, in case that’s relevant.
Thanks!
Insert “xkcd” for everything. I am happy with the move to disallowing system pip install at least.
I think it should be a punishable offence to share Python scripts that depend on third-party packages without any ready-to-go bundling/isolation :)
goes for any interpretted language where dependencies inevitably creep into the global namespace via distribution packagers that should know better :P
I dislike installing python dependencies globally.
It’s like keeping your vacuum cleaner, lawnmower, and washing machine in your living room.
Someone mentioned virtualenv which I expect is the best way to encapsulate a set of python dependencies.
That said, nix package manager on debian (not nixos) will provide the same encapsulation in a language agnostic way. As in, you can use it for python or node or rust or binaries or cli tools or GUI apps or anything really.
Learning about nix just to run this one script is an over engineered solution, but I feel like its worth a mention because its definitely the best way to run anything you want in a way that won’t clutter up your living room.
The details for creating a shell with python dependencies are here:
Hey when pip doesn’t work:
You’re using Debian, so if you don’t want to set up virtual environments the best bet is to install your dependencies using apt like a normal person. All the python stuff in apt will show up under the prefix python3-. So you’ll need python3-numpy, python3-tiffile etc.
Apt supports tab completion so something like “apt install python3-num” then the tab key would show a list of possible completions (and jump forward any letters that are common between completions).
If you want to use venvs there’s a bunch of posts explaining how to do that.
When you want to “install” the .py doohicky you just downloaded, put it in your path! $PATH will tell you what locations get scanned for executable files when you type something and you can add a local directory like ~/.bin to it, then put your .py file in there. If you go with venvs, put the .py file in the right place to run inside the venv, then make a one liner script that runs it from the venv with the file name set to what you wanna type to run the .py, put it in your local path directory and you’re off to the races!
I also use Debian and am coerced into using python software so reply with any questions and I’ll set you straight.
You can run it in an virtual environment:
python -m venv someproject
source someproject/bin/activate
Then you can run the commands in the git README you posted.
pip …
Will will install the include files needed within this virtual environment. Alternatively you can do
apt install …
Instead of using pip. Your python script should run within the virtual environment.
What’s the difference between doing this and just using pipx?
That might work but it is recommended to not install packages outside of virtual environments as it might lead to conflicts between versions across different projects.
Just FYI, pipx does use a virtual environment behind the scenes. The idea with pipx or uvx is to install a python script as a standalone script.
I did not know that, I assumed they wrote pipx to mean pip/pip3. Thanks for pointing that out.
You don’t need to “Install” them like in Windows. Everything in Linux is just a call to launch something, and for Python is just
python someprogram.py.If you’re regularly going to be calling this program, you can put it anywhere makes sense for you, but generally somewhere in your PATH, and then you can make an alias for your preferred terminal to launch it easily.
If that’s super confusing, give this a try (cross platform): https://github.com/InkAurora/PythonAliasManager
Other comments did a good job
Just making sure, how familiar are you with using the terminal?
The GitHub repository you linked is terminal-only
I’d recommend installing those python dependencies using apt, so that when you update your system packages, the python libraries get updated, too. Pip, on the other hand, is useful for development but is detatched from apt and you will definitely forget to pip update unlike apt update which you hopefully do frequently. Use the names of the packages the readme provides in the pip install … instruction. For example, for numpy, you can install this.
Then, since that python script has a shebang at the top, you can add it to a directory in your $PATH and mark it executable with chmod, and you can invoke the script in your shell from any directory with just the file name.



