Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to not install package with pip to anaconda

I have problem about pip.

When I want to install some package, for instance flask, It wants to install it to /anaconda3.

juldou@juldou-machine:~$ pip install flask
Requirement already satisfied (use --upgrade to upgrade): flask in ./anaconda3/lib/python3.5/site-packages

I know that I already have flask, but I don't want install it to anaconda.

How to exit pip of anaconda and set other environment, or what to do with it? Sorry, but I don't understand basics of concept.

like image 320
Július Marko Avatar asked Mar 28 '16 19:03

Július Marko


People also ask

Can you install Python packages without pip?

Most Python packages are now designed to be compatible with Python's pip package manager. But if you have a package that is not compatible with pip, you'll need manually install Python packages.

Do I need pip if I have Anaconda?

Both pip and conda are included in Anaconda and Miniconda, so you do not need to install them separately. Conda environments replace virtualenv, so there is no need to activate a virtualenv before using pip. It is possible to have pip installed outside a conda environment or inside a conda environment.

Should I install packages with Conda or pip?

You should install pip inside your conda environment and use pip in that conda environment (only) when conda-formatted packages are not available from the major conda repos (like conda-forge or anaconda.org).


1 Answers

The command pip belongs to whatever python environment it was installed in. The exact binary that is executed when you run a command are determined by your PATH environment variable and whatever executable is found first is executed. In your case your Anaconda environment is in your PATH before your system python. If you have a virtualenv or conda sub-environment and want to use executables from those, then "activating" those environments should make those available.

So your choice is to either specify the full path to pip and python and whatever executables you want to run from your non-anaconda environment:

/path/to/my_other_env/bin/pip install flask

Or to not add Anaconda to your PATH (most likely in your .bashrc or .bash_profile) or to prepend your PATH with the path to your non-anaconda's bin directory:

export PATH=/path/to/my_other_env/bin:$PATH
pip install flask

However, doing this will break your normal workflow with Anaconda so things like the following probably won't work anymore:

source activate <conda-env>

If you removed Anaconda from your PATH entirely then you also won't be able to find the conda command without specifying the full path to it:

/path/to/anaconda/bin/conda update ...
like image 92
djhoese Avatar answered Sep 24 '22 18:09

djhoese