You are not logged in.

#1 Yesterday 17:56:17

callmejoe
Member
Registered: 2019-03-06
Posts: 78

[Solved]Do I need multiple python virtual environment for each package

do i need to create separate virtual environments for each externally managed python package I want to install.  Or can I install several packages to the same venv?

Thanks

Last edited by callmejoe (Today 04:15:51)

Offline

#2 Yesterday 22:34:21

bulletmark
Member
From: Brisbane, Australia
Registered: 2013-10-22
Posts: 670

Re: [Solved]Do I need multiple python virtual environment for each package

Are you asking about Python based applications you want to install to run? Or Python packages you want to install to develop/import into your own app etc?

The point of a venv is to completely isolate applications and have no possibility of package version clashes etc. We all tend to have huge and under-used hard disks and most of the venvs are small anyhow so you really are better off keeping installed applications isolated. Use `pipx` (or an equivalent tool) to install, update, and remove such applications. `pipx` will create an isolated venv for the app and then create a symlink to the executable in your personal PATH. Of course, you are better off sticking to system or AUR provided packages for such apps if you can and only use `pipx` for applications not available otherwise, or to get a later version.

If you are asking about packages you want to install for your own use, e.g. for developing an app, then you would typically create a single venv in your project directory and install all the required packages into that. E.g. list your required packages in a requirements.txt file (specifying explicit versions if you want) and:

python -m .venv
.venv/bin/pip install -r requirements.txt

Offline

#3 Today 01:16:14

callmejoe
Member
Registered: 2019-03-06
Posts: 78

Re: [Solved]Do I need multiple python virtual environment for each package

thanks bulletmark

I needed to install a specific python package to import into a script.  The one i needed was not in the repos or aur.  I did try using pipx but gave me an error: "No apps associated with package wayfire or its dependencies. If you are attempting to install a library, pipx should not be used. Consider using pip or a similar tool instead."

so i set up a a virtual env with python -m venv /opt/python and installed the python package there.  maybe i should have used python -m venv /opt/python/wayfire and then future projects under /opt/python/fooX to better manage them.

Seems like there are some nuances and personal preferences that go into how to manage these external packages.

I'll keep refining as I go.  thanks again.

Offline

#4 Today 02:40:50

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,165
Website

Re: [Solved]Do I need multiple python virtual environment for each package

callmejoe wrote:

I needed to install a specific python package to import into a script.  The one i needed was not in the repos or aur.

Then make a PKGBUILD for it.  There's a template PKGBUILD for any package available via pip.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 Today 04:14:59

callmejoe
Member
Registered: 2019-03-06
Posts: 78

Re: [Solved]Do I need multiple python virtual environment for each package

Trilby wrote:

Then make a PKGBUILD for it.  There's a template PKGBUILD for any package available via pip.

yes that is a good suggestion. i'll do just that.

Offline

Board footer

Powered by FluxBB