1

I have installed python 3.6 and python 2.7. Currently the default version of python running on Terminal is python 2.7. I would like to install a package based on python 3.6. So first I need to change the default version of python from 2.7 to 3.6 in terminal. How can I do this?

I have tried to use virtual environment, but I am afraid that virtual environment is only working when you are trying to use commands of python 3.6, instead of installing a package in python 3.6.

Thanks

Zero Piraeus
  • 56,143
  • 27
  • 150
  • 160
  • 5
    Don't, just use terminal command `python3` instead of just `python` – Taku Nov 16 '17 at 02:52
  • Update system path pointing to python 3.6 instead of 2.7 – Quinn Nov 16 '17 at 02:57
  • @abccd, Thanks! But I am currently installing a package in python 3.6 using lots of commands, such as "python setup.py build" or "python setup.py install --user". I have changed "python" to "python3" in those commands, but didn't work. –  Nov 16 '17 at 03:15
  • @Quinn, I know it's trivial, but could you please tell me how to update system path to python 3.6 on Mac? Thanks a lot! –  Nov 16 '17 at 03:15
  • @MuhanZhao: I don't have Mac environment, but it should be similar to Linux/Unix. I recommend you have a look at https://stackoverflow.com/questions/6819661/python-location-on-mac-osx. 1) Check out what's the location of python (e.g. `$ ls -l /usr/local/bin/python`); 2) If default is python 2.7, then you can remove the above symbol link (e.g. rm /usr/local/python ); 3) create a new symbol link to python 3.6 (of course, you should know the location of python 3.6): e.g. ln -s /path/to/python3.6 /usr/local/python. Just for your reference, be sure to know what you are doing with those commands. – Quinn Nov 16 '17 at 03:56
  • 2
    Don't ever forcibly change the system Python path to be a different version as you will likely break parts of your operating system which rely on the original version. Go use a Python virtual environment based off version you want to use and work in that. It will give you a ``python`` in your PATH regardless of the Python version. – Graham Dumpleton Nov 16 '17 at 11:24
  • @MuhanZhao `python3 setup.py build` *should* work. If it doesn't work, ask about *that* instead. – Antti Haapala -- Слава Україні Nov 16 '17 at 11:29
  • @AnttiHaapala Thanks! I have tried that method, and it works! Appreciate that! –  Nov 16 '17 at 19:37

0 Answers0