问题
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
...
..
.
I want to install conda
and have Python 2.7
and Python 3.6
environment.
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.
回答1:
Install same versions
First, get a list of packages installed via pip into a file:
pip freeze > packages.txt
Then install them using conda inside your two environments:
conda install --yes --file packages.txt
Install ignoring versions
pip freeze
will spit out packages with versions. To remove them, run this instead:
pip freeze | sed s/=.*// > packages.txt
This way you will more likely succeed in installing them using conda without getting dependency conflicts.
Anticipating PackagesNotFoundError
If you have a lot of packages installed, conda might fail to find some of them. In that case, check out this question.
回答2:
Downloading conda and installing multiple python versions are given here and also you can find many important commands related to conda. https://github.com/Nitish1206/conda_setup_for_ubuntu
Install pip packages in conda via.
*while read requirement; conda install --yes $requirement;or pip install $requirement; end < requirements.txt*
来源:https://stackoverflow.com/questions/51864477/transfer-pip-packages-to-conda