I am in a bit of a problem, as a server was upgraded, and some old python environments are no longer working. I cannot just activate the environment, but I would like to create a new environment which is a replica of the old environment to the extent possible.
This means installing on the new environment the same version of packages from the old environment.
Is there a way to extract this information from the old environment, for example, into a requirements.txt file? There doesn't seem to be anywhere a requirements.txt file in the old environment I can use.
EDIT: Thank you for the discussion. Yes, it was my mistake for not doing pip freeze before the upgrade, but I wasn't aware things are that flimsy.
Some of the code is old (and I know I will get comments about python 2.7 being used in some of the cases), but for example, when I run pip freeze from one of the activated packages I get:
# pip freeze
/.../venv/bin/python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
I know python 2.7 is installed on the machine, but I looked through all files in the whole server for this object file, and couldn't find it.
Here is a shell script which roughly approximates the functionality of
pip freeze. I have tested it on an environment where I knew the answer (the Charcoal SmokeDetector project) and the results are approximately right; but there are many Python packages whose package names do not precisely align with the file names.In addition to that, this has the usual problems of
pip freeze; it will list all installed packages, not just the ones you explicitly requested. So if for example you wanted to install the packagese7enand it has a dependency onsix, thensixwill also be included in the output, even if it will obviously be unnecessary if a future version ofse7endrops the dependency onsix.For the Smokey dependencies, the above script displays warnings for
dns(the actual package name isdnspython),attr(I think the actual package name isattrsbut it weirdly creates a directory with the singular form),msgpack(the actual package name ismsgpack-python), andpkg_resources(does not expose a version number). It could arguably be changed to fix a few of these one way or another, but there are then probably other corner cases which are left uncovered. Consider this a rough sketch anyway.