Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conda: installing local development package into single conda environment

If I were using a virtualenv, I would activate my project's virtual environment then install the package I am developing in develop mode. Something like the following:

workon superbad
pip install -e fnawesome

This allows my package fnawesome to be accessible with any code updates in my superbad virtual environment. If I switch to any other environment, including the default environment, superbad id not accessible.

How are people doing similar setups using conda?

like image 433
brent.payne Avatar asked Jan 05 '14 00:01

brent.payne


People also ask

Does conda install packages for each environment?

To automatically add default packages to each new environment that you create: Open Anaconda Prompt or terminal and run: conda config --add create_default_packages PACKAGENAME1 PACKAGENAME2. Now, you can create new environments and the default packages will be installed in all of them.

Can I mix pip and conda?

pip is the standard package manager for python, meaning you can use it both inside and outside of Anaconda.

What is the difference between conda install and pip install?

The fundamental difference between pip and Conda packaging is what they put in packages. Pip packages are Python libraries like NumPy or matplotlib . Conda packages include Python libraries (NumPy or matplotlib ), C libraries ( libjpeg ), and executables (like C compilers, and even the Python interpreter itself).


2 Answers

You can configure a list of default packages that will be installed into any conda environment automatically

conda config --add create_default_packages pip --add create_default_packages ipython

will make it so that conda create will always include pip and ipython in new environments (this command is the same as adding

create_default_packages:
  - ipython
  - pip

to your .condarc file).

To create an environment without these, use conda create --no-default-packages.

like image 182
asmeurer Avatar answered Sep 21 '22 17:09

asmeurer


Okay, I figured out the issue behind the question.

If you create a conda environment, make sure to include pip and ipython. Otherwise, it will not setup the path to point to environment specific versions of these utilities.

so:

conda create -n superbad scikit-learn
source activate superbad
pip install -e fnawesome  # (installs in default env b/c pip is global pip)
ipython  # runs global ipython with access to global site packages
python # runs the environment's python with no access to fnawesome

this works as expected:

conda create -n superbad scikit-learn pip ipython
source activate superbad
pip install -e fnawesome  # installing into superbad site packages
ipython  # runs superbad ipython
python  # runs the environment's python with access to fnawesome
source deactivate
ipython # no access to fnawesome
like image 36
brent.payne Avatar answered Sep 19 '22 17:09

brent.payne