Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I have been suffering from this venv problem as well. Anyone know if there is a programme or effort to dedup dependencies across projects or something? Feels like it is probably doable.


You can create a virtual environment that you don't source/activate (for your projects), then you can use that to `pip install` the libraries you want to share and add that to your `PYTHONPATH`.

Since your `PYTHONPATH` searches in order your project virtual environment will override any other libraries you have in your path, say with different version.

It will look something like this:

    PYTHONPATH=${PWD}:${HOME}/envs/shared/lib64/${PYTHONVERSION}/site-packages/


Will pip also see that and not install what’s installed there? This is most useful in AI tools, but they tend to have their own “setup” process that pip-installs everything regardless. If not, it’s no use.


Yeah it should, it pretty much just checks what's in the installed libraries of the given project/path.

I typed it up: https://git.sr.ht/~jlambda/docs/tree/docs/item/python/python...


Thanks!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: