Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved] Q: Use python 2.7 when 3.2 is set to default
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
solamour
Guru
Guru


Joined: 21 Dec 2004
Posts: 484
Location: San Diego, CA

PostPosted: Sun Nov 11, 2012 8:36 am    Post subject: [Solved] Q: Use python 2.7 when 3.2 is set to default Reply with quote

I have python 3.2 as default.

Code:
# eselect python list
Available Python interpreters:
  [1]   python2.6
  [2]   python2.7
  [3]   python3.2 *


Everything works fine, except "repo" command for Android development, which is not compatible with python 3.x (Google says so http://source.android.com/source/building.html).

In a given bash session, is there a way to use python v2.7 as default in that particular session without making any changes to the system's default setting?
__
sol


Last edited by solamour on Sun Nov 11, 2012 10:30 pm; edited 1 time in total
Back to top
View user's profile Send private message
chithanh
Developer
Developer


Joined: 05 Aug 2006
Posts: 1559
Location: Berlin, Germany

PostPosted: Sun Nov 11, 2012 1:34 pm    Post subject: Reply with quote

Note that your link only says that python-2 must be installed, not that it must be set as default.

Normally it is sufficient to change the shebang lines of affected python scripts from
Code:
#!/usr/bin/env python
to
Code:
#!/usr/bin/env python2
If that is not feasible in your case, you can set the environment variable EPYTHON="python2.7" but that is not guaranteed to work without problems.
Back to top
View user's profile Send private message
solamour
Guru
Guru


Joined: 21 Dec 2004
Posts: 484
Location: San Diego, CA

PostPosted: Sun Nov 11, 2012 10:30 pm    Post subject: Reply with quote

When I run "repo" command, it downloads other python scripts, which in turn require python 2.x, so making changes to the script itself turned out to be more hassle.

But "export EPYTHON=python2.7" did the trick. Everything is working well now. Thank you. I believe "EPYTHON" is gentoo-specific environment variable, yes?
__
sol
Back to top
View user's profile Send private message
yngwin
Developer
Developer


Joined: 19 Dec 2002
Posts: 4394
Location: Suzhou, China

PostPosted: Mon Nov 12, 2012 4:04 am    Post subject: Reply with quote

Why don't you set 2.7 as the default? In my opinion python3 is still not ready for prime-time. I would even completely get rid of the other versions, if I were you, unless you use something that specifically needs 3.2.
_________________
"Those who deny freedom to others deserve it not for themselves." - Abraham Lincoln
Free Culture | Defective by Design | EFF
Back to top
View user's profile Send private message
solamour
Guru
Guru


Joined: 21 Dec 2004
Posts: 484
Location: San Diego, CA

PostPosted: Mon Nov 12, 2012 6:36 am    Post subject: Reply with quote

yngwin wrote:
Why don't you set 2.7 as the default? In my opinion python3 is still not ready for prime-time.


Agreed. There are too many things out there that are not playing nicely with python 3 (Django, for example). That said, I believe python 3 is where we are headed (http://wiki.python.org/moin/Python2orPython3), and if I'm going to be there eventually, I might as well start sooner rather than later.

Besides, other than this "repo" thingy, I didn't have much trouble using python 3 as the default. Then again, I'm just starting to learn, so I don't have much to lose anyway.
__
sol
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum