How to get the path where pip installs `data_files`?

Viewed 244

Running pip install seems to create the directory structure + files specified in data_files in /usr/local

However, if I run:

import sys
sys.prefix

I get the string /usr.

Is there any way to figure out where pip installed the data_files for a specific package in a distribution/OS agnostic way ?

Note: I am installing a package from a github repostiroy instead of pypi so maybe this results in the different behavior ?

1 Answers

I believe you should work with sysconfig.

First try:

path/to/pythonX.Y -m sysconfig

And then try its get_path function:

import sysconfig

data_path_str = sysconfig.get_path('data')
print("data_path_str", data_path_str)
Related