Specific reasons to favor pip vs. conda when installing Python packages

前端 未结 6 2001
花落未央
花落未央 2020-12-13 20:15

I use miniconda as my default python installation. What is the current (2019) wisdom regarding when to install something with conda vs. pip?

My usual behavior is to

6条回答
  •  情歌与酒
    2020-12-13 21:00

    Note: The following recommendations are now part of the official documentation.


    "What is the current (2019) wisdom regarding when to install something with conda vs. pip?"

    Anaconda Inc's Jonathan Helmus sums this up quite nicely in the post "Using Pip in a Conda Environment." Here's an excerpt from the final best practices recommendation:

    Best Practices Checklist

    Use pip only after conda

    • install as many requirements as possible with conda, then use pip
    • pip should be run with --upgrade-strategy "only-if-needed" (the default)
    • Do not use pip with the --user argument, avoid all “users” installs

    Use Conda environments for isolation

    • create a Conda environment to isolate any changes pip makes
    • environments take up little space thanks to hard links
    • care should be taken to avoid running pip in the root [base] environment

    Recreate the environment if changes are needed

    • once pip has been used conda will be unaware of the changes
    • to install additional Conda packages it is best to recreate the environment

    Store conda and pip requirements in text files

    • package requirements can be passed to conda via the --file argument
    • pip accepts a list of Python packages with -r or --requirements
    • conda env will export or create environments based on a file with conda and pip requirements

提交回复
热议问题