0

Suppose if there is a python script which uses libraries like numpy, pandas, keras, tensorflow etc.

Now how do I download all the libraries locally so that script is not breaking due to any updates in libraries.

What I mean is what if certain library is discontinued in future and I want to use it to a different machine where it wasn't installed before. What can be done here?

Stupid_Intern
  • 3,382
  • 8
  • 37
  • 74
  • If a library gets an updated, it won't be updated in your code, unless you explicitly do it. You can also choose a specific older version of a library if your code was built on it, without having to install the last one. If you can access to where the script was running, you can actually get the library that were used with their specific version https://stackoverflow.com/questions/31684375/automatically-create-requirements-txt – Aymen Dec 28 '22 at 11:02
  • Your last edit: if a certain library become deprecated, you can keep using it in your code. – Aymen Dec 28 '22 at 11:04

1 Answers1

0

You should create a virtual environment into which the specific releases of your dependencies, such as numpy and pandas are installed with pip after having activated the virtual environment. Then you can either (1) activate the virtual environment prior to running your script or explicitly add a shebang to the virtual environment's bin (e.g. Linux) or Scripts (e.g. Windows) directory:

#!/path_to_virtual_environement/bin/python
...

This is a general approach that should be used for all of your applications so that each application's library dependencies are neatly encapsulated within its own virtual environment. This makes it easier to migrate the application to another machine since all of its dependencies can readily be determined.

Booboo
  • 38,656
  • 3
  • 37
  • 60