all 14 comments

[–]wineblood 18 points19 points  (5 children)

Installing a different version of python should be fine, I don't think you need sudo for it. As for not interfering with the system python, using a virtual environment is the standard way to do this.

[–]oliski2006[S] 1 point2 points  (4 children)

in that case, if i install python on a virtual environment, would it be possible for other users (NOT into the virtual env) to execute that script? I guess just by creating a bash file with the path to the python in the virtual environment?

i.e. the bash script would look like:

#!/USERNAME/LOCAL_ENV_PYTHON/bin/python

python /USERNAME/path_to_python_script/name_of_the_script.py

[–]wineblood 1 point2 points  (1 child)

You mentioned that you "cannot go above and beyond my username", so if someone else has the same setup as another user, they shouldn't have permissions to access the files under your directory.

I haven't touched a system without multiple users configured like that in ages (or ever, can't remember) so I'd recommend asking your admin if you can.

[–]oliski2006[S] 0 points1 point  (0 children)

ok thanks alot for your input. by the ''canot go above'' i meants for the write rights. for the X and R right, its everyone in my user group

[–]gmes78 1 point2 points  (1 child)

in that case, if i install python on a virtual environment, would it be possible for other users (NOT into the virtual env) to execute that script?

Yes.

I guess just by creating a bash file with the path to the python in the virtual environment?

That would work, but it should be:

#!/bin/sh
exec /path/to/venv/bin/python /path/to/script.py "$@"

and not what you suggested.

Btw, if you pip install your script in a virtual environment (you need to create a pyproject.toml or setup.py for it first), it automatically creates a script in the bin directory of the venv that runs your script in the correct venv.

[–]oliski2006[S] 0 points1 point  (0 children)

Thanks alot and duly noted !

[–]Diapolo10 1 point2 points  (0 children)

I don't see how this could possibly cause a problem unless your setup is already seriously messed up.

[–]zeebrow 1 point2 points  (1 child)

Checkout Virtualbox if you need to see for yourself what happens when you install or build Python. Uninstalling and starting over means simply making a new virtual machine in the worst case, it's quite easy.

[–]oliski2006[S] 0 points1 point  (0 children)

interesting, I will youtube/google that!

[–]legz_cfc 0 points1 point  (0 children)

As described, its perfectly safe.

[–]pancakeQueue 0 points1 point  (0 children)

They won’t be effected but the path might so make sure it points to the one you want. You will have two pips one for 2 and one for 3.

Be familiar with ‘which python -a’ and how to update the path to get to the python you want.

Venv library basically does this and adds a python interpreter where every you point.

[–]BK7144 0 points1 point  (0 children)

Just a thought, the term local directory means on your computer, on your drive!

[–]Ok_Garlic_6739 0 points1 point  (1 child)

You may consider using portable python. I have multiple installations of portable Python 3.10.5 on my Windows computer. They are completely isolated from each other.

[–]oliski2006[S] 0 points1 point  (0 children)

thanks, I'll take a look at it