Ask coding questions

← Back to all posts
Where are the files of installed Python packages stored?
PaoloAmoroso (132)

I’m trying to understand where stores the files of Python packages downloaded from PyPI, particularly executable scripts.

Consider for example the pep8 style checker that can be run from a Linux shell by executing the pep8 script. If I use the REPL’s package manager to install this package the script is nowhere in PYTHONPATH. Under '/home/runner/.site-packages', which is listed in sys.path, there’s a file that seems the right one but it’s not a directly executable script like the pep8 one mentioned in the package’s documentation.

More generally, where does store any installed executable (i.e. that have the +x permission set) bash or Python files in a Python REPL?

PaoloAmoroso (132)

I checked again pep8 and other packages that provide executable scripts, such as pytest and cookiecutter. It looks like the package manager now does automatically add to the system path any executable scripts or directories that come with the packages.

This is likely a recent development, thanks to the team.

PaoloAmoroso (132)

Thanks to this post and the reply by @NicolasRedmond I found the scripts Python packages install can be run from the shell with python -m scriptname, i.e. python -m pep8 in my original example.

21natzil (1091)

Sorry, I can't answer this questions. However maybe I can suggest a work-around, assuming you're trying to run pep8. If you type python3 -m pep8, that should run it all the same.

PaoloAmoroso (132)

@21natzil Thanks. However, using pep8 is an example and my question is more general. I'm wondering about the executable scripts of other packages and apps.