-4

So, as the support for Python 2 is coming to an end and some libraries are only available in Python 3. I want to shift from 2 to 3, but dont want to uninstall and do the installation again. Is there another way to do so and how?

Also, I have Anaconda with Python 2 in which there's a virtual environment that runs Python 3.

Can I have both? Not as virtual!

  • You don't need to uninstall python 2, just install python 3. Both are still widely supported, but when running python 3 via console you need to specify `python3 `. And when running something in 2.7, just use `python` – Aroic Dec 16 '19 at 18:38

1 Answers1

1

Note: I have done both solutions myself for my Windows 10 and Ubuntu 19 installations but I just renamed my python to python3 on windows, and it works fine. I have both installed currently even though I only use python 3 because cygwin and some google tools still rely on it.

Windows

Use the installer from python.org and the installer will install it alongside python 2. To run from the console you can run py -3 or you can create a batch file in your new python 3 directory to run it using the command python3 such as python3.bat || python3.cmd:

.\python %*

to make sure it runs from the command line correctly

Linux

Most linux distros come with python 2 installed automatically, just run your package manager such as apt install python3 or whatever your package manager is.

Xander Bielby
  • 161
  • 1
  • 12
  • Does this add anything to the preexisting answers on the [question that was already proposed as a duplicate](https://stackoverflow.com/questions/3809314/how-to-install-both-python-2-x-and-python-3-x-in-windows)? (Please keep in mind the guidance regarding "questions that have been asked and answered multiple times before" in the *Answer Well-Asked Questions* section of [How to Answer](https://stackoverflow.com/help/how-to-answer); coalescing duplicate questions means we can collect as many answers as possible in one place, and have them effectively ranked against each other & edited). – Charles Duffy Dec 16 '19 at 20:44
  • That note did not exist when I answered the question, and while it is a common question it was a distraction from what I was doing at that time, so in that respect worthwhile – Xander Bielby Dec 16 '19 at 20:48
  • I only closed it just now, but there was a comment (auto-deleted when the close operation took place) that was preexisting from the first proposal of duplicate flagging. Anyhow -- I'm not saying the question, or your answer, isn't worthwhile; I'm saying that the answer should be added *only on the canonical instance of the question* so it's ranked against other answers there (and so folks finding this question are linked to the widest array of proposed answers possible, rather than being likely to stop at the first one). – Charles Duffy Dec 16 '19 at 20:50
  • Thank you! Let me try this.I will inform you if it something happens. – Huzefa Jambughoda Dec 18 '19 at 19:57