How to install highest version of a Python package which doesn't break my App?

170 views Asked by At

Do you anchor all versions in requirements.txt to a spesific number? Is it the right way? Is there any way to get latest version that does not break my app? To not missing security updates etc.

1

There are 1 answers

0
Chandral On

Installing latest dependency may break your app if the new code syntax is not backwards compatible. Here's how I approach to maintain the requirements.txt file.

  • Create a new virtual environment every time I develop for a new project
  • Install all the dependencies in the virtual env
  • Run pip freeze > requirements.txt from that virtual env to generate the file
  • Add Python version in a Readme file

This way I can always know for sure the Python version and version of the dependencies with which the app was built. This of course does not solve other issues related to OS type/version compatibility that might occur.

Tools like Docker are created to solve all such dependency and cross-platform compatibility problems so that is worth exploring.

EDIT

If you still want to always have the latest version of the package, simply remove the version numbers and keep the package name.

E.g. Instead of mysql-connector==2.2.9 use mysql-connector