We manage a significant number of Python virtual code environments in our estate. We are moving to a more aggresive OS level patching schedule which means there is higher risk to break some Python virtual code environments due to some OS level dependencies changing or issues during installation. We are therefore looking at different options to try to mitigate this risk. Aside from recreating the virtual code environment after OS patching what else can we do to confirm the code environment it's working fine? Of course running the code/app/model that the code environment is meant to support would be ideal but this is not practical/possible for various reasons that are not relevant to the question.
I was thinking that perhaps I could look at the requirements.txt of each virtual code environment and attempt to import all packages that required to be installed in each virtual code environment. From previous experience the majority of virtual code environment issues happen either during the creation of the code environment (ie when packages are installed/code env created) or when the required packages are imported in code. So this approach will cover most of the risk leaving only potential run time issues which should be a very small proportion.
What's you view on this approach? Do you see any issues with it? One thing I know will be a challenge is that package names don't always match the "import" name used in code but I suspect we will be able to work around this problem building a dictionary of package names and import names.
Process
I believe this should be done in a two step procedure

Create environment for testing (OS / Python Version)
Run a set of integration tests to determine pass state

Step 1 ensures you can create a environment which accurately represents what will be used in production.
Step 2 ensures you can test the environment and make sure it does what you expect.
Then all you have to do is repeat this procedure for each environment, adding  additional tests as you see fit.
Creating an environment
This can be done in many ways:

Docker containers
Virtual machines using IaC provisioning
Manual config (not repeatable)

Manual config is not repeatable and would be slow.
Running Integration Tests
This is dependent on what you are testing but could be done with

Bash / Python Scripts
Web API calls
File discovery
Other low level system calls
How can I test Python virtual code environments programatically?