How to add package to conda environment without pip?

放肆的年华 提交于 2019-12-03 08:33:49

问题


How can I add a package to an existing conda environment?

If it is a python package I can use pip install <package>, but what if pip does not work?

Is it sufficient to activate the environment and use conda install <package>?


回答1:


You've answered your own question. In fact you really want to do conda install ... instead of using pip if you can.

You can install a conda package also without activating the environment. Just use conda install -n <env_name> <package> or conda install -p <path/to/env> <package>.




回答2:


If you want to install a specific package inside a specific conda environment, you can use the following command.

First activate the conda environment and then do:

$ conda install --name <conda_env_name> -c <channel_name> <package_name>

For a concrete example, let's assume that you want to install chainer from the channel anaconda to an already created conda environment named chainerenv, then you can do:

$ conda install --name chainerenv -c anaconda chainer



回答3:


There's an alternative way to do this and I have just tested it on my own mac:

example: i want to install a non-conda package at my python2.7 environment:

  1. go to terminal

  2. activate the desired environment by: source activate py27

  3. after you successfully activated the environment, you can install the package you wanted by: pip install package




回答4:


The answer is yes (usually). One example is that you can activate your conda environment and then directly do conda install pandas.tar.bz2 on the existing tar.bz2 files from /conda_envs/.pkgs (leftovers from other environments) If you don't have a tarball package like that but you have the src with setup.py you can just do the usual install by python setup.py install (or python setup.py develop to link the src)



来源:https://stackoverflow.com/questions/33680946/how-to-add-package-to-conda-environment-without-pip

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!