Finding current executable’s path without /proc/self/exe

Some OS-specific interfaces: Mac OS X: _NSGetExecutablePath() (man 3 dyld) Linux: readlink /proc/self/exe Solaris: getexecname() FreeBSD: sysctl CTL_KERN KERN_PROC KERN_PROC_PATHNAME -1 FreeBSD if it has procfs: readlink /proc/curproc/file (FreeBSD doesn’t have procfs by default) NetBSD: readlink /proc/curproc/exe DragonFly BSD: readlink /proc/curproc/file Windows: GetModuleFileName() with hModule = NULL There are also third party libraries that can … Read more

How can I make a Python script standalone executable to run without ANY dependency? [duplicate]

You can use PyInstaller to package Python programs as standalone executables. It works on Windows, Linux, and Mac. PyInstaller Quickstart Install PyInstaller from PyPI: pip install pyinstaller Go to your program’s directory and run: pyinstaller yourprogram.py This will generate the bundle in a subdirectory called dist. pyinstaller -F yourprogram.py Adding -F (or –onefile) parameter will … Read more