Optional dependencies in a pip requirements file

前端 未结 3 545
旧巷少年郎
旧巷少年郎 2020-12-13 12:33

How can I specify optional dependencies in a pip requirements file?

According to the pip documentation this is possible, but the documentation doesn\'t explain how t

3条回答
  •  没有蜡笔的小新
    2020-12-13 13:06

    Instead of specifying optional dependencies in the same file as the hard requirements, you can create a optional-requirements.txt and a requirements.txt.

    To export your current environment's packages into a text file, you can do this:

    pip freeze > requirements.txt
    

    If necessary, modify the contents of the requirements.txt to accurately represent your project's dependencies. Then, to install all the packages in this file, run:

    pip install -U -r requirements.txt
    

    -U tells pip to upgrade packages to the latest version, and -r tells it to install all packages in requirements.txt.

提交回复
热议问题