Best way to make new python application from 4 years old application

We have python application made 4 years old ago . this application work with python 3.6 right now and we have requirements.txt file. and we go to the folder of this application ans make virtual environment by python and after that use source for activate it. and after that we use pip3.6 for install requirements of this project and after make we run this project by uwsgi and run it by Nginx.

Right now we want make this project by python 3.9

our problem is requirement , some of these requirement is not compatible by new python 3.9 and its pip packages.

How we can solve this problem and compatible this project by python 3.9 and new pip packages?

You will need to port the code to use the updated packages.
There is no magic short cut.

We can offer help here if it is not clear what code changes you need to make. What errors are you seeing?

1 Like

I build this project by python 3.7 too and it work like charm.
but with python 3.9 , I see error about pip install and some of packages can not find and some packages are not compatible by python 3.9.
How I can tell pip install packages are compatible with python 3.9?
How I can tell pip install and old packages worked on python3.6 on python3.9?

pip automatically looks for packages that are compatible with the version of python you are using.

If the packages that you used for 3.6 are not marked as compatible with 3.9 then you cannot expect them to work.

Further help requires you to share the output of pip and the requirements.txt file you are using.

I see error

ERROR: Could not find a version that satisfies the requirement tensorflow==1.5.0 (from versions: 2.5.0, 2.5.1, 2.5.2, 2.5.3, 2.6.0rc0, 2.6.0rc1, 2.6.0rc2, 2.6.0, 2.6.1, 2.6.2, 2.6.3, 2.6.4, 2.6.5, 2.7.0rc0, 2.7.0rc1, 2.7.0, 2.7.1, 2.7.2, 2.7.3, 2.7.4, 2.8.0rc0, 2.8.0rc1, 2.8.0, 2.8.1, 2.8.2, 2.8.3, 2.8.4, 2.9.0rc0, 2.9.0rc1, 2.9.0rc2, 2.9.0, 2.9.1, 2.9.2, 2.9.3, 2.10.0rc0, 2.10.0rc1, 2.10.0rc2, 2.10.0rc3, 2.10.0, 2.10.1, 2.11.0rc0, 2.11.0rc1, 2.11.0rc2, 2.11.0, 2.11.1, 2.12.0rc0, 2.12.0rc1, 2.12.0, 2.12.1, 2.13.0rc0, 2.13.0rc1, 2.13.0rc2, 2.13.0, 2.13.1, 2.14.0rc0, 2.14.0rc1, 2.14.0)
ERROR: No matching distribution found for tensorflow==1.5.0

old project work with tensorflow 1.5.0

Ok you will need to use a newer version of tensionflow and change your code as needed. 2.14 is the current version.

That will go for all the pinned versions you are using.

I recommend that you update to the latest versions of all dependencies and then pin on those versions.

As an aside: you are showing that if you do not update your code for a long time there is a cost in porting it when you are forced to change.

That is the cost you are paying now.

The alternative is to regularly update your code so that the changes are easier to manage.
You are more likely to find people that know about recent changes then ones made may years ago.

Personally I have found the keep up to date is cheaper on engineer time.
But can be a hard sell to management unless there is security involved.
Then its easy old == more-security-problems new == less-security-problems.

1 Like

after I use 2.5.0 of tensoflow I see this error

import tensorflow.contrib.slim as slim
ModuleNotFoundError: No module named 'tensorflow.contrib'

You will need to research where that came from and what the replacement is. I cannot help you with that specific error.
Try a web search for the error and see if you find a solution.
Also you may find there is a docs for porting from V1 to V2 of the tensorflow package that will tell you what to do.

1 Like

but I hear pip can install packages from specific time, but I can not find that option.

You can install old compatible versions. But there are none.
You will have to do the port, you cannot avoid paying down your technical debt.

1 Like

Can I use this for solve problem?

ERROR: After October 2020 you may experience errors when installing or updating packages. This is because pip will change the way that it resolves dependency conflicts.                                           
We recommend you use --use-feature=2020-resolver to test your packages with the new resolver before it becomes the default.  

Sigh… You cannot avoid the porting work!

And no that will not help…


“Under the hood, TensorFlow 2 follows a fundamentally different programming paradigm from TF1.x.”
See: TensorFlow 1.x बनाम TensorFlow 2 - व्यवहार और API  |  TensorFlow Core

Apparently the tensorflow devs also realized that the design of v1 was pretty lousy, so they did what Google devs do - they completely rewrote it (Kind of similar to what happened with Angular.) I’m glad I’m not in your shoes, but since you will need to do a substantial migration of your code now, I would seriously consider going one step further and just use torch instead…

But if you want to stick with TF, then there is a separate forum for further problems you might run into
when migrating or after migrating to v2:

[Somehow there seems to be bug in Discourse related to rendering of links. The link in this post sometimes appears as Hebrew and sometimes as Japanese in my browser. It’s a regular English link however.]