将Pip包转移到conda [英] Transfer Pip packages to conda
问题描述
我目前正在使用共享的Ubuntu计算机,该计算机具有 python2.7 和通过 pip 安装的多个软件包.
I am currently using a shared Ubuntu machine which has python2.7 and multiple packages installed via pip.
$ python --version
Python 2.7.12
$ pip --version
pip 18.0 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
$ pip list
Package Version
---------------------------------- -----------
asn1crypto 0.24.0
awscli 1.11.101
backports-abc 0.5
...
..
.
我要安装 conda
,并具有 Python 2.7
和 Python 3.6
环境.
I want to install conda
and have Python 2.7
and Python 3.6
environment.
如何在conda env( 2.7
和 3.6
)中安装当前已安装的所有软件包( pip list
)?我不关心软件包的版本.可以为每个软件包安装相同版本或最新版本.
How can I install all the packages currently installed (pip list
) in both conda env (2.7
and 3.6
) ? I am not concerned with package version. Fine to install the same version or latest version for each package.
推荐答案
安装相同版本
首先,获取通过pip安装到文件中的软件包列表:
Install same versions
First, get a list of packages installed via pip into a file:
pip freeze > packages.txt
然后在两个环境中使用conda安装它们:
Then install them using conda inside your two environments:
conda install --yes --file packages.txt
安装忽略版本
pip Frozen
将吐出带有版本的软件包.要删除它们,请运行以下命令:
Install ignoring versions
pip freeze
will spit out packages with versions. To remove them, run this instead:
pip freeze | sed s/=.*// > packages.txt
这样,您将更有可能使用conda成功安装它们,而不会发生依赖关系冲突.
This way you will more likely succeed in installing them using conda without getting dependency conflicts.
如果您安装了很多软件包,conda可能找不到其中一些.在这种情况下,请查看此问题一个>.
If you have a lot of packages installed, conda might fail to find some of them. In that case, check out this question.
这篇关于将Pip包转移到conda的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!