Last answered:

13 Jan 2022

Posted on:

26 Oct 2021

0

Resolved: How do you set up different python version in your machine and when do we need it?

I download python 3.7 but I found some online codes do not run on 3.7 and do on 3.8 and the same the other way around, how do you approach this type of thing? and how do you solve it? Do you set up different environments on different versions of python? How frequently do you update your python version?

2 answers ( 1 marked as helpful)
Posted on:

30 Oct 2021

5

Although you provide no specific examples, it is hard to see how simple beginner examples would not run on Python 3.7 versus 3.8. Conda is a package and environment manager.
so:
conda create --name py34 python=3.4              - Creates a python environment called py34 running python 3.4

conda create --name py37 python=3.7              - - Creates a python environment called py37 running python 3.7

Check the conda cheat sheet. https://docs.conda.io/projects/conda/en/4.6.0/_downloads/52a95608c49671267e40c689e0bc00ca/conda-cheatsheet.pdf
I update my python environment rarely unless I am dealing with a project that requires a specific package of a specific version of python, or if there are packages that clash with each other.

A.G.

Posted on:

13 Jan 2022

0

the solution to run different python versions is virtual environment (venv). it is quite straightforward under linux but you have to do your own homework for details.

in professional developer world it is always recommended to work different projects in  separate virtual environment so you keep your code secure from changing libraries which could decrepit your application in the future.

the basic idea is that  the venv could be built on the top of the main python installation and only contains the specific libraries you need or contains the entire python in itself along with the application you develop. then you can move these information altogether when you pass the app to a different user or machine.

Submit an answer