当前位置: 首页 > news >正文

Python - ~=

 

branching_venv = BranchPythonVirtualenvOperator(task_id='branching_venv',requirements=['numpy~=1.26.0'],venv_cache_path=VENV_CACHE_PATH,python_callable=branch_with_venv,op_args=[options]
)

In the above code snippet, what does the numpy~=1.26.0 mean?

 

In a Python requirement specifier, the operator ~= means “compatible release”.

So:

numpy~=1.26.0

means:

➡️ Use a version of NumPy that is ≥ 1.26.0 but < 1.27.0

In other words, it will accept:

  • 1.26.0

  • 1.26.1

  • 1.26.2


  • but not 1.27.0 or higher.

This is often used when you want to allow bug-fix upgrades within the same minor version, but avoid breaking changes from the next minor release.