Can the third-party library files that python update to before 3.10 be copied directly?

It seems to be under the Lib folder.
Is there any convenient way to migrate the library files in the past?

It seems like you are asking to be able to re-use the packages you had installed for a prior version of Python, with Python 3.10?

Is that correct? If so, while it may be possible, it is not recommended and you should re-install those packages using Python 3.10.

1 Like

This is true under normal circumstances, but for those who have a lot of packages, it may be a waste of time to install one by one. It is actually quite good if there are import tools.

While I can understand your desire to make things simpler, it’s just not practical to ‘import’ from the site-packages folder of a previous installation. Here are some reasons why, there are likely many more:

  • The versions of the packages installed there may not be compatible with the new version of Python, so newer versions could be required.

  • Some of the packages installed there may include non-Python code (C, C++, etc.) and thus have to be installed specifically for the version of Python being used.

  • Some of the installed packages may not be compatible with the new version of Python and there are no versions which are.

As a starting point, you could run pip freeze in the older version of Python, capture the output into to a file (named anything, but I’ll use package-list.txt) and then run pip install -r package-list.txt in the new version of Python. If all of the installed packages came from PyPI (or whichever index pip is configured to use), and all of the versions previously installed can be used with the new version of Python, then that process would install all of them in one pass. As noted above though there are many reasons why this may not work.

1 Like

Thanks for your reply, this is a good way.

See this thread for an example of what happens when code written for one version or Python gets moved into a different version:

My guess is that the person running the code accidentally, or deliberately, copied the dateutils from one site-packages to another.

1 Like