如何在 Anaconda (Conda) 环境中跟踪 pip 安装的软件包? [英] How do I keep track of pip-installed packages in an Anaconda (Conda) environment?
问题描述
我已经安装并一直在使用 Anaconda Python 发行版,并且我已经开始使用 Anaconda (Conda) 环境.我可以使用标准的 conda install...
命令将分发包中的包放入我的环境中,但要使用外部的任何东西(即 Flask-WTF、flask-sqlalchemy 和 alembic),我需要使用pip install
在活动环境中.但是,当我查看环境的内容时,无论是在目录中,还是使用 conda list
,这些 pip install
ed 包都不会显示.
I've installed and have been using the Anaconda Python distribution, and I have started using the Anaconda (Conda) environment. I can use the standard conda install...
command to put packages from the distribution into my environments, but to use anything outside (i.e. Flask-WTF, flask-sqlalchemy, and alembic) I need to use pip install
in the active environment. However, when I look at the contents of the environment, either in the directory, or using conda list
these pip install
ed packages don't show up.
使用 pip freeze
和 pip list
只会列出我安装过的每个包.
Using pip freeze
and pip list
just lists every package I've ever installed.
有没有办法跟踪我的每个 Anaconda env
(安装了 pip
和 conda
)中的内容?
Is there a way to keep track of what is in each of my Anaconda env
s (both pip
and conda
installed)?
推荐答案
conda-env 现在会自动执行此操作(如果 pip 与 conda 一起安装).
conda-env now does this automatically (if pip was installed with conda).
您可以使用用于迁移环境的导出工具来了解其工作原理:
You can see how this works by using the export tool used for migrating an environment:
conda env export -n <env-name> > environment.yml
该文件将列出 conda 包和 pip 包:
The file will list both conda packages and pip packages:
name: stats
channels:
- javascript
dependencies:
- python=3.4
- bokeh=0.9.2
- numpy=1.9.*
- nodejs=0.10.*
- flask
- pip:
- Flask-Testing
如果您想继续导出环境,请将 environment.yml
移动到新主机并运行:
If you're looking to follow through with exporting the environment, move environment.yml
to the new host machine and run:
conda env create -f path/to/environment.yml
这篇关于如何在 Anaconda (Conda) 环境中跟踪 pip 安装的软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!