3

Without root access, how do I change the default Python from 3.5 to 2.7 for my specific user? Would like to know how to run Python scripts with Python 2 as well.

If I start up Python by running simply python then it runs 3.5.2. I have to specifically run python2 at the terminal prompt to get a version of python2 up.

If I run which python, then /data/apps/anaconda3/bin/python gets returned and I believe Python 2.7 is under /usr/bin/python.

This is on CentOS if that helps clarify anything

jfs
  • 399,953
  • 195
  • 994
  • 1,670
simplycoding
  • 2,770
  • 9
  • 46
  • 91
  • Possible duplicate of [Two versions of python on linux. how to make 2.7 the default](http://stackoverflow.com/questions/19256127/two-versions-of-python-on-linux-how-to-make-2-7-the-default) – MaLiN2223 Nov 11 '16 at 20:24
  • python 2.7 is the default on centos. Perhaps you should add an "anacoda" tag to this question because its more of a "why did anaconda mess up my centos" thing. The convention is that "python" is python 2 and "python3" is python 3. I'm not sure why they've messed with that but anything to attract anaconda users to your question would help. – tdelaney Nov 11 '16 at 20:43
  • General questions that would be useful: How did you install anaconda? Did you stick with the defaults or did you change your PATH variable or something? Are you running in a virtualenv when you hit the problem? – tdelaney Nov 11 '16 at 20:47
  • No idea how Anaconda was installed. I'm just another user, so I have no knowledge on the PATH variable and whatnot. – simplycoding Nov 11 '16 at 22:04

2 Answers2

3

You can add

alias python=python2.7

to your .bashrc file in home folder

Yevhen Kuzmovych
  • 10,940
  • 7
  • 28
  • 48
1

If you are looking to change the python interpreter in anaconda from 3.5 to 2.7 for the user, try the command conda install python=2.7