You are not logged in.

#1 2016-03-28 17:50:21

shelbydz
Member
Registered: 2014-03-16
Posts: 58

[SOLVED] changing /usr/bin/python symlink

Hi,

I run awesome wm, vim, chrome and not much else. I develop in python for a living. But we use 2.7. It looks like the default /usr/bin/python is linked to python 3.5. Would I break any core Arch stuff by changing that to python 2.7? It would make my life a lot easier.

thx

Last edited by shelbydz (2016-03-30 11:28:01)

Offline

#2 2016-03-28 18:10:59

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,719

Re: [SOLVED] changing /usr/bin/python symlink

Might I suggest virtualenv

ewaller@turing/home/ewaller % python
Python 3.5.1 (default, Mar  3 2016, 09:29:07)
[GCC 5.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
ewaller@turing/home/ewaller % virtualenv2 venv
New python executable in /home/ewaller/venv/bin/python2
Also creating executable in /home/ewaller/venv/bin/python
Installing setuptools, pip, wheel...done.
ewaller@turing/home/ewaller % source venv/bin/activate
(venv) ewaller@turing/home/ewaller % python
Python 2.7.11 (default, Mar  3 2016, 11:00:04)
[GCC 5.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
(venv) ewaller@turing/home/ewaller % pacman -Qo virtualenv2
/usr/bin/virtualenv2 is owned by python2-virtualenv 15.0.0-1
(venv) ewaller@turing/home/ewaller %

Edit:  Sorry, I did not really answer your question.  Changing your links to Python2 will break things.  A lot of things. 
The solution I proposed changes the PATH for the current process and future spawned sub-processes so that Python 2 is found first.  Also, things installed using pip are local to that environment and don't impact the global space.  In the mean time, other windows (processes) will still use the global version.

Last edited by ewaller (2016-03-28 18:42:55)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#3 2016-03-28 18:46:12

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,729

Re: [SOLVED] changing /usr/bin/python symlink

shelbydz wrote:

Hi,

I run awesome wm, vim, chrome and not much else. I develop in python for a living. But we use 2.7. It looks like the default /usr/bin/python is linked to python 3.5. Would I break any core Arch stuff by changing that to python 2.7? It would make my life a lot easier.

thx

So call /usr/bin/python2 like you should be doing anyway.
http://legacy.python.org/dev/peps/pep-0394/

Offline

#4 2016-03-28 18:47:33

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 13,715
Website

Re: [SOLVED] changing /usr/bin/python symlink

I realise that this isn't what you asked, but you could "make your life a lot easier" by using appropriate shebangs instead of relying on /usr/bin/python being what you want: https://www.python.org/dev/peps/pep-0394/


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#5 2016-03-28 18:50:35

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,719

Re: [SOLVED] changing /usr/bin/python symlink

Of course, if one reads the posts my colleagues linked, it seems our distribution's policies were the genesis of that pep wink


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#6 2016-03-30 11:27:50

shelbydz
Member
Registered: 2014-03-16
Posts: 58

Re: [SOLVED] changing /usr/bin/python symlink

Okay, thanks everyone. I did modify the shebang. That seems to be the easiest solution. These scripts are shared across multiple environments, including Ubuntu and OSX. The better alternative is probably a virtual environment.

thx

Offline

#7 2016-03-30 11:35:12

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

Re: [SOLVED] changing /usr/bin/python symlink

shelbydz wrote:

The better alternative is probably a virtual environment.

"Better" based on what?  The better alternative is to do it properly from the start which means using the right shebang.  The links you've been provided with are not arch-specific guidelines, they are python coding guidelines.


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

Offline

Board footer

Powered by FluxBB