Python Forum
Upgrade to python 3 opinion - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: News and Discussions (https://python-forum.io/forum-31.html)
+--- Thread: Upgrade to python 3 opinion (/thread-33572.html)



Upgrade to python 3 opinion - hokie1999 - May-07-2021

Question on getting started for upgrade from python 2 to python 3:

We here at my company run python 2.7.5 on IDS-type and automation-controlled CentOS 7 servers.

A while back, we installed an app on one of our servers that required python 3. We added, at the advice of the vendor, these packages:

python35u-3.5.6-1.ius.centos7.x86_64
python35u-libs-3.5.6-1.ius.centos7.x86_64


Is it correct to say that, if we want to keep python 2 functionality, but we need python 3 functionality on all our servers for a new app, and we don't want python 3 to interfere -- that is, we want both python 2 and python 3 to function without issues -- that we are safe to install the above two packages on all (about 300) of our servers?

I'm looking for an opinion here. Thanks! Smile


RE: Upgrade to python 3 opinion - Gribouillis - May-07-2021

I don't know much about CentOS and I don't run 300 servers, but normally several Python interpreters on the same machine don't interfere. The main thing to worry about is the use of Python-related environment variables such as PYTHONPATH and the like. Avoid them, or fine tune the environment of processes using the Python interpreters.

If you could have Python 3.6 instead of 3.5, it would be much better from a pythonic perspective. 3.6 introduces some key new features such as f-strings. You may experience problems running new Python 3 code if you stick to 3.5.


RE: Upgrade to python 3 opinion - nilamo - May-07-2021

Maybe?
If you're not relying on whatever "python" resolves to, and are using direct references (ie: calling python2.7 my_app.py instead of python my_app.py), then it doesn't matter. You could install 20 different versions of python and they wouldn't interfere with each other.

If it's a big concern, why not run it on it's own server(s) and access it over a rest interface?


RE: Upgrade to python 3 opinion - snippsat - May-08-2021

(May-07-2021, 02:47 PM)hokie1999 Wrote: Is it correct to say that, if we want to keep python 2 functionality, but we need python 3 functionality on all our servers for a new app, and we don't want python 3 to interfere -- that is, we want both python 2 and python 3 to function without issues -- that we are safe to install the above two packages on all (about 300) of our servers?
Look into using pyenv is a safe option and can switch seamlessly between Python versions.
My Tutorial pyenv Simple Python Version Management
For Centos Pyenv Install Centos 8 .
Wiki for all OS.


RE: Upgrade to python 3 opinion - Skaperen - May-11-2021

i have both Python 2.7.17 and Python 3.6.9 on my Xubuntu 18.04 LTS based laptop without using pyenv. i just don't code for Python 2. But i did need to run some old scripts on Python 2 to have a reference. i believe Python 3 was intended to coexist with Python 2, at least until the EOL date, 1 Jan 2020. i see no reason for it to have been changed since then.

if you have any Python 2 scripts that other tools run or other people use, don't use pyenv for Python 2. likewise, if you will be rewriting them to Python 3 (as you should have long ago) don't use pyenv for Python 3, either.

it sounds like you have a lot to upgrade, there.

edit1: changed "p;d" typo to "old"


RE: Upgrade to python 3 opinion - hokie1999 - May-11-2021

Ok, thanks for the input. :)