Skip to content Skip to sidebar Skip to footer

Is It Possible To Install Part Of Python Package Via Pip?

I have an internal utility library that is used by many projects. There is quite a bit of overlap between the projects in the code they pull from the utility library, but as the li

Solution 1:

Not directly, to my best knowledge. pip installs a package fully, or not at all.

However, if you're careful in your package about how you import things that may require psycopg2 or someotherlargebinarything, you could use the extras_require feature and thus have the package's users choose which dependencies they want to pull in:

setup(
  # ...
  name='myawesometoolbelt',
  extras_require={
    'db': ['psycopg2'],
    'math': ['numpy'],
  },
)

and then, in your requirements.txt, or pip invocation,

myawesometoolbelt[db,math]

Solution 2:

Have you tried looking at pip freeze > requirements.txt and pip install -r requirements.txt?

Once you generated your pip list via pip freeze, it is possible to edit which packages you want installed and which to omit from the requirements.txt generated. You can then pip install -r requirements.txt the things you want back in.

Post a Comment for "Is It Possible To Install Part Of Python Package Via Pip?"