Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[gentoo-user] how to set python version for one user

145 views
Skip to first unread message

p...@xvalheru.org

unread,
Jul 10, 2018, 4:30:03 AM7/10/18
to
Hi,

I need to set specific python version to a user and I don't want to set
it up for whole system. Is it possible? If so how to do it. All I found
is about setting for whole system.

Thanks

Pat

----------------------------------------
Freehosting PIPNI - http://www.pipni.cz/

Alexander Kapshuk

unread,
Jul 10, 2018, 5:20:03 AM7/10/18
to
How about this?
echo alias python='python2.7' >> ~user/.bash_profile

Helmut Jarausch

unread,
Jul 10, 2018, 5:30:03 AM7/10/18
to
On 07/10/2018 10:23:05 AM, p...@xvalheru.org wrote:
> Hi,
>
> I need to set specific python version to a user and I don't want to
> set
> it up for whole system. Is it possible? If so how to do it. All I
> found
> is about setting for whole system.
>
> Thanks
>
> Pat
>

A simple method would be to set up the PATH for this user to prepend a
local folder,
.e.g $HOME/bin

Then copy (or symlink) the desired Python version from /usr/bin to that
folder under
a different name (i.e. without the (full) version number)

Helmut

p...@xvalheru.org

unread,
Jul 10, 2018, 8:10:03 AM7/10/18
to
On 2018-07-10 11:19, Alexander Kapshuk wrote:
> On Tue, Jul 10, 2018 at 11:23 AM <p...@xvalheru.org> wrote:
>>
>> Hi,
>>
>> I need to set specific python version to a user and I don't want to
>> set
>> it up for whole system. Is it possible? If so how to do it. All I
>> found
>> is about setting for whole system.
>>
>> Thanks
>>
>> Pat
>>
>>
> How about this?
> echo alias python='python2.7' >> ~user/.bash_profile
>

Well, this one doesn't work in case at the beginning of the python
script is:
#!/usr/bin/env python

I have a "lot of scripts" with this. What I've thought there will be
possibility to setup python version per user similar as for gcc (I
think).

Thanks for help

p...@xvalheru.org

unread,
Jul 10, 2018, 8:20:03 AM7/10/18
to
Thanks I'll check this.

p...@xvalheru.org

unread,
Jul 10, 2018, 9:30:03 AM7/10/18
to
On 2018-07-10 14:09, p...@xvalheru.org wrote:
> On 2018-07-10 11:22, Helmut Jarausch wrote:
>> On 07/10/2018 10:23:05 AM, p...@xvalheru.org wrote:
>>> Hi,
>>>
>>> I need to set specific python version to a user and I don't want to
>>> set
>>> it up for whole system. Is it possible? If so how to do it. All I
>>> found
>>> is about setting for whole system.
>>>
>>> Thanks
>>>
>>> Pat
>>>
>>
>> A simple method would be to set up the PATH for this user to prepend a
>> local folder,
>> .e.g $HOME/bin
>>
>> Then copy (or symlink) the desired Python version from /usr/bin to
>> that
>> folder under
>> a different name (i.e. without the (full) version number)
>>
>> Helmut
>>
>>
>
> Thanks I'll check this.
>
> Pat
>

Thanks Helmut, it works.

Ralph Seichter

unread,
Jul 10, 2018, 10:20:04 AM7/10/18
to
On 10.07.2018 10:23, p...@xvalheru.org wrote:

> I need to set specific python version to a user and I don't want to
> set it up for whole system. Is it possible?

I can't tell if by "set it up" to have Python binaries available for
only one user, or if you want one user to use a different Python version
from other users, with multiple Python versions potentially available to
all users, which would be then "Gentoo way".

If you have, for example, Python 2.7 and 3.6 installed, you can use
"eselect python set ..." to configure the default Python for most users.
For individual users, I recommend a Python virtual environment. You can
use the 'virtualenv' module for both Python 2.7 and 3.x, but since Python
3.5 the built-in 'venv' module is recommended.

I know soft links to a specific Python version were recommended here,
but based on my experience I strongly discourage that. Your special user
will need more than just the binaries, and a venv is definitely the more
robust and versatile way to go.

-Ralph

Mike Gilbert

unread,
Jul 10, 2018, 6:30:03 PM7/10/18
to
On Tue, Jul 10, 2018 at 4:23 AM, <p...@xvalheru.org> wrote:
> Hi,
>
> I need to set specific python version to a user and I don't want to set it
> up for whole system. Is it possible? If so how to do it. All I found is
> about setting for whole system.

On Gentoo, you can set the EPYTHON environment variable.

floppym@naomi ~ % python --version
Python 3.6.6
floppym@naomi ~ % export EPYTHON=python2.7
floppym@naomi ~ % python --version
Python 2.7.15
0 new messages