5

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.

Július Marko
  • 1,096
  • 4
  • 15
  • 35
  • Where do you want to install it? Where ever that is, you need to use the `pip` from that python environment. The `pip` being used when you type that command is whatever is found first in your `PATH`. You could call pip by doing `/path/to/my_other_env/bin/pip install flask`. – djhoese Mar 28 '16 at 19:50
  • for instance, I want to setup my virtualenv by typing `virtualenv project_sql`, but in this case i must do `following? /usr/local/lib/python3.5/site-packages/virtualenv project_sql` – Július Marko Mar 28 '16 at 20:12
  • Do you use your anaconda environment a lot? Is that why you have it in your PATH? Why not an anaconda sub-environment instead of a virtualenv? Somewhere in your .bash_profile or .bashrc or something you are adding the anaconda environment to your PATH. If that's not something you want then don't do it, but then `source activate ` won't work out of the box either. – djhoese Mar 28 '16 at 20:23

1 Answers1

5

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 ...
djhoese
  • 3,193
  • 24
  • 42
  • this worked: `cd C:\Users\User\AppData\Local\Programs\Python\Python36\Scripts` then `pip install xx` – JinSnow Apr 03 '18 at 16:14