Python Forum
Running three-year old python code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Running three-year old python code
#1
If someone has some python 3 code that is say three years old how does one run it? Say it has no requirmenets.txt file so one must run it by one's wits.

By that I mean since it is three year old code then the chances are that the current Python interpreter is not going to run it.
I have to guess which Python interpreter was current in that period.

Of course, the battle does not stop there, all the supporting files such as numpy, and matplotlib must match the python interpreter of that period. So this is all guesswork.

If the code came with a requirements.txt file that would be good. But there is still the issue of whether the apps from that period are even available inthe preent day.

I just need some advice on this.

Respectfully,

ErnestTBass
Reply
#2
If it's Python 3.x code, any 3.x version of the interpreter should be capable of running it. A compatibility issue would only arise if it's a Python 2.7 code because of certain changes made with version 3.1.

Likewise, the modules you've listed are well maintained and should not have compatibility issues either.

Have you attempted to run the code? Did the interpreter raise an error?
Reply
#3
Hi.

Well thinking aloud there may a few ways to do this depending on the amount of effort you want to put in and what you intend to run it on, for example, me personally i would run something like pyenv or create a number of various virtual environments, first taking the later of the python versions say 3.8.2 and within a suitable IDE see what errors it throws at you, something like pyCharm for instance will use intellisense and tell you what packages are missing and what it can cater for, now what it wont do potentially is cater for say some functions that did it way X and now do it way Y (aka upgraded per se) but if the end result is what is expected / needed then happy days. If the version flags up say loads of deprecated functions then with pyenv / virtualenv / venv create a number of back ported versions until it works, same with those other packages but would do the main python ones first, there will of course be a point when maybe the version that works is "too old" and then perhaps you need to make a judgement call as to whether you modernise it.
I have not used sublime but VSC or pyCharm will do the aforementioned and fairly effectively, they also allow you to change quickly between various python virtualenvs (having created them beforehand)
Regards
-------- *
“Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read.”
Reply
#4
Okay, you have convinced me. My question is how does one keep up with all of the changes made in Python. Is there some Oracle that keeps a record of all the changes?

Respectfully,

ErnestTBaass
Reply
#5
(Jun-19-2020, 02:56 AM)ErnestTBass Wrote: My question is how does one keep up with all of the changes made in Python.
There is what's new page on releases.
Example What’s New In Python 3.6
Python 3.6 was the biggest and most important release in the Python 3 saga,with 16 new PEP(Python Enhancement Proposals).
Raymond Hettinger Wrote:Python 3.6.1 is the first of the Python 3 series that I think is worthy of calling itself an improvement over 2.7.
As example What’s New In Python 3.8.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python to 10-year-olds Krayna 4 1,004 Jun-09-2023, 08:54 AM
Last Post: Naviewater9426
  compiling but not running source code Skaperen 1 1,292 Jun-05-2022, 10:47 PM
Last Post: Gribouillis
  running produced python code Skaperen 6 1,855 Dec-25-2021, 05:52 PM
Last Post: Skaperen
  code running after tracebacks Skaperen 0 1,237 Oct-03-2021, 12:09 AM
Last Post: Skaperen
  [split] the best python teaching program for an 8 year kid? ThomasMoore 2 2,340 Apr-16-2019, 09:12 PM
Last Post: Larz60+
  Recovering lost source code when the code is running in memory micseydel 13 9,526 Apr-14-2017, 02:35 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020