432

conda 4.2.13 MacOSX 10.12.1

I am trying to install packages from pip to a fresh environment (virtual) created using anaconda. In the Anaconda docs it says this is perfectly fine. It is done the same way as for virtualenv.

Activate the environment where you want to put the program, then pip install a program...

I created an empty environment in Ananconda like this:

conda create -n shrink_venv

Activate it:

source activate shrink_venv

I then can see in the terminal that I am working in my env (shrink_venv). Problem is coming up, when I try to install a package using pip:

(shrink_venv): pip install Pillow

Requirement already satisfied (use --upgrade to upgrade): Pillow in /Library/Python/2.7/site-packages

So I can see it thinks the requirement is satisfied from the system-wide package. So it seems the environment is not working correctly, definitely not like it said in the docs. Am I doing something wrong here?

Just a note, I know you can use conda install for the packages, but I have had an issue with Pillow from anaconda, so I wanted to get it from pip, and since the docs say that is fine.

Output of which -a pip:

/usr/local/bin/pip
/Users/my_user/anaconda/bin/pip

** UPDATE ** I see this is pretty common issue. What I have found is that the conda env doesn't play well with the PYTHONPATH. The system seems to always look in the PYTHONPATH locations even when you're using a conda environment. Now, I always run unset PYTHONPATH when using a conda environment, and it works much better. I'm on a mac.

jeffery_the_wind
  • 17,048
  • 34
  • 98
  • 160
  • 43
    Did you try a `conda install pip`? – languitar Dec 09 '16 at 12:24
  • 8
    can you add the output of `which -a pip` to your question please? – cel Dec 09 '16 at 12:25
  • @cel just added that output, yes I can see I have 2 different versions of pip installed. – jeffery_the_wind Dec 09 '16 at 12:29
  • 3
    Do you have a `PYTHONPATH` environment variable set? – darthbith Dec 09 '16 at 15:28
  • 1
    had a similar issue. Explicitly using the pip that is part of Anaconda seemed to work for me. – Arsene Lupin Apr 28 '17 at 22:50
  • @ArseneLupin How? – Little Bobby Tables Jan 15 '18 at 15:29
  • "*the Anaconda docs say this is perfectly fine*" Not really: using `pip` is allowed but it definitely has serious pitfalls and is not interoperable. Please refer to ["Using Pip in a Conda Environment"](https://www.anaconda.com/using-pip-in-a-conda-environment/) for some updated recommendations. – merv Aug 20 '19 at 22:51
  • 2
    Just do `python -m pip install Pillow` – intsco Mar 30 '20 at 21:16
  • 1
    is it really safe to install things using pip and conda? I thought you could get into issues, like not knowing which version to fix uninstall... – Charlie Parker Jul 03 '20 at 18:55
  • 1
    @Charlie Parker yes it is safe, but I might point out the accepted answer by Windmill. This works great for me. After first creating a conda environment, you then install pip in the environment first then use that installation to install packages into environment. I recently created an environment which uses some important packages from conda repos and other from pip and it all works together nicely. For example the recommended installation of tensorflow is through pip and not conda. – jeffery_the_wind Jul 08 '20 at 13:17
  • In your writing please distinguish between `anaconda`, `conda` and "Anaconda" the commercial company. These are quite different entities. `conda` is a totally open source utility that is 100% separate from the Anaconda commercial entity. anaconda is a metapackage which bundles together the installation instructions for the core Python packages in an Anaconda data science distribution: see the following link for a good explanation https://www.anaconda.com/blog/whats-in-a-name-clarifying-the-anaconda-metapackage – Rich Lysakowski PhD Apr 09 '23 at 05:47

21 Answers21

585

For others who run into this situation, I found this to be the most straightforward solution:

  1. Run conda create -n venv_name and conda activate venv_name, where venv_name is the name of your virtual environment.

  2. Run conda install pip. This will install pip to your venv directory.

  3. Find your anaconda directory, and find the actual venv folder. It should be somewhere like /anaconda/envs/venv_name/.

  4. Install new packages by doing /anaconda/envs/venv_name/bin/pip install package_name.

This should now successfully install packages using that virtual environment's pip!

Jules G.M.
  • 3,624
  • 1
  • 21
  • 35
Deem
  • 7,007
  • 2
  • 19
  • 23
  • 17
    Has the path for the `bin` folder changed? I'm not longer seeing it in the `venv_name` folder? – Jack Sep 30 '18 at 15:21
  • Just tried creating a new venv, looks like the `bin` is still in the same place. – Deem Nov 04 '18 at 23:47
  • 5
    Didn't have 'bin' folder so the above steps helped. One thing I would add is running 'which pip' helps to determine which 'pip' is actually installing packages and 'pip freeze' gives the list of installed in the environment packages – Mykola Jan 17 '19 at 15:36
  • 4
    I have situation where even though my source is activated, my installations are not happening in the environment. They are installed in the default python location. – Saisumanth Gopisetty Mar 13 '19 at 00:17
  • 23
    This answer is largely: Run `pip` from your conda env (whether it's the environment or not), and install the package that you want using the `pip` executable within the conda folder (my case: `AppData\Local\Continuum\anaconda3\Scripts`) – Manuel Martinez May 16 '19 at 20:04
  • 1
    There's actually no need to do `source activate venv_name`, simply install with `conda install -n venv_name pip` and then directly using pip from there (as you suggest - btw: thanks!) – Alex Nov 22 '19 at 13:10
  • 8
    Isn't there a way to have the pip which is associated with the current conda env run seamlessly when I run `pip` while in that env? (Instead of indicating the full path as step 4 requires). – Yoav Vollansky Apr 25 '20 at 14:20
  • 3
    I didn't have a need for step 3 or 4 since I checked `which pip` and it already pointed to the correct bin – Daniel V May 23 '20 at 01:45
  • If you don't know your environment directory, before step 3 execute: $which python$. This will give you the directory of your environment. – skdhfgeq2134 Jul 06 '20 at 05:36
  • Keep in mind that your anaconda directory may be located at ~/anaconda3 instead of /anaconda. – Shivang Patel Jul 18 '20 at 00:22
  • 2
    @Jack The `bin` folder was neither present in my python 3.6 environment in Anaconda 4.8.3. The comment of Manual Martinez worked, as it contained the `pip.exe` file. So one could replace the command of step 4 with: `..../Anaconda3/envs/venv_name/Scripts/pip install package_name` if you don't have the `bin` folder in folder `venv_name`. – a.t. Aug 07 '20 at 09:01
  • just running step 2 alone seemed to work perfectly for me on macOS. by not running the other steps am I risking an improper installation? – Joseph Farah Nov 04 '20 at 04:45
  • 1
    [This](https://stackoverflow.com/a/56889729/1519409) is the best answer. Activate your conda environment with `conda activate env_name`, and then use the local copy of pip within the environment by running `python -m pip install package_name`. – inavda Dec 21 '20 at 06:57
  • [alex_danielssen's answer](https://stackoverflow.com/a/56889729/1048186) helped me confirm that `pip install ...` works in my case: `which -a pip` shows /home/me/.conda/myenv/bin/pip`. – Josiah Yoder Mar 09 '21 at 15:34
  • Sounds great -- but ... what happens to packages that are different in conda? Let's say I install miniconda, and pip as above and then I install a package that depends on numpy via conda's pip. Does the pip or conda version of numpy get installed? – user48956 Apr 14 '21 at 20:00
  • As for step 3, note that Conda environment is available at $CONDA_PREFIX environment variable, which is auto-generated in step 1. – Shahar Gino May 18 '21 at 18:33
  • it's easier and safer to specify python version to use when creating environment `conda create environment -n yourenvname python=3.10` – taiyodayo Nov 09 '21 at 03:20
  • I would like to merge step 3 and step 4 with ````$(which pip) install package_name```` – Albert G Lieu Nov 15 '21 at 18:10
  • Not sure why I can't edit this answer, but in step 3, if you are trying to find the location of your anaconda environment, refer to this page: https://stackoverflow.com/questions/35709497/anaconda-python-where-are-the-virtual-environments-stored – Jeff Ellen Apr 28 '22 at 21:09
  • 2
    On Mac M1 the path could be `/opt/anaconda3/envs/env-name/bin/pip` – Euler_Salter Jun 20 '22 at 14:08
133

I solved this problem the following way:

If you have a non-conda pip as your default pip but conda python is your default python (as below)

>which -a pip
/home/<user>/.local/bin/pip   
/home/<user>/.conda/envs/newenv/bin/pip
/usr/bin/pip

>which -a python
/home/<user>/.conda/envs/newenv/bin/python
/usr/bin/python

Then instead of just calling pip install <package>, you can use the module flag -m with python so that it uses the anaconda python for the installation

python -m pip install <package>

This installs the package to the anaconda library directory rather than to the library directory associated with (the non-anaconda) pip

EDIT: The reason this works is as follows: the command pip references a specific pip file/shortcut (which -a pip tells you which one). Similarly, the command python references a specific python file (which -a python tells you which one). For one reason or another these two commands can become unsynchronized, so that your 'default' pip is in a different folder than your default python, and therefore is associated with a different version of python.

In contrast, the python -m pip construction does not use the shortcut that the pip command points to. Instead, it asks python to find its version of pip and use that version to install a package.

alex_danielssen
  • 1,839
  • 1
  • 8
  • 19
  • 20
    This should be the answer. Works perfectly on Windows. – Geordie Dec 16 '19 at 21:14
  • 7
    Absolutely, this should be the answer. The other solutions didn't work and this one is even more elegant. – Fips Oct 11 '20 at 07:23
  • 2
    Yup, this is the cleanest and most effective answer. Works on Ubuntu. – inavda Dec 21 '20 at 06:54
  • 1
    "If you have a non-conda pip as your default pip" this certainly voids the whole merits of using conda to create and manage reproducible environments? – taiyodayo Nov 09 '21 at 03:22
  • 1
    @taiyodayo: that wasn't the question. Having a non-conda pip set as default seems to be a situation many people, myself included, have found themselves in. The answer above provides a way to solve the problem presented in the question under a certain circumstance. – alex_danielssen Nov 09 '21 at 23:06
  • not work:Done above steps. But: python -m pip install stt /usr/bin/python3: No module named pip (env-stt) – gdm Dec 12 '21 at 16:14
  • @gdm : I think you might have a different problem altogether, which is that your default python does not have the pip module installed. – alex_danielssen Dec 13 '21 at 16:56
  • @alex_danielssen Very nice solution !!! But can you explain why 'pip install' failed? I thought "pip install" should have the same function with "python -m pip install". – Jingnan Jia Jan 16 '22 at 11:03
  • @JingnanJia I've updated the answer with an explanation of why this works. – alex_danielssen Jan 17 '22 at 16:04
  • 1
    I'm really glad that I ran into this solution. – Jim O. Feb 23 '22 at 21:04
  • 2
    Thanks, it works wonderfully for Mac, have been struggling with this for hours. – Sandbo Aug 25 '22 at 06:47
  • 1
    Very nice solution, works on Ubuntu! – Quan Bui Aug 26 '22 at 05:01
  • Awesome. But is there any ways to make `python -m pip` default and use it like `pip`? – Tina J Aug 20 '23 at 23:10
  • I had to resort to `pip --python ~/miniconda3/envs//bin/python install ` where is the name of the conda environment. I also have `pyenv` installed and that seems to interfere – David Waterworth Aug 23 '23 at 07:00
124

All you have to do is open Anaconda Prompt and type

pip install package-name

It will automatically install to the anaconda environment without having to use

conda install package-name

Since some of the conda packages may lack support overtime it is required to install using pip and this is one way to do it

If you have pip installed in anaconda you can run the following in jupyter notebook or in your python shell that is linked to anaconda

pip.main(['install', 'package-name'])

Check your version of pip with pip.__version__. If it is version 10.x.x or above, then install your python package with this line of code

subprocess.check_call([sys.executable, '-m', 'pip', 'install', '--upgrade', 'package-name'])

In your jupyter notebook, you can install python packages through pip in a cell this way;

!pip install package-name

or you could use your python version associated with anaconda

!python3.6 -m pip install package-name
sambeth
  • 1,550
  • 2
  • 10
  • 18
  • 16
    how do you "open Anaconda prompt" – Thomas Browne Sep 15 '17 at 14:41
  • 5
    On windows you have to search for 'anaconda prompt' using the search icon or input found on the task bar and open – sambeth Sep 15 '17 at 16:43
  • 1
    @sambeth on mac? – Parthapratim Neog Dec 02 '17 at 08:30
  • I'm not a mac user, so I can't help here. – sambeth Dec 04 '17 at 12:19
  • 2
    I think the key is to run your anaconda's pip, which sits under your anaconda global or specific environment. – matanster Mar 11 '19 at 15:07
  • 27
    This answer is incorrect. The whole point of the question is that sometimes it *doesn't* install into the environment. It installs globally. To prevent that, you need to first run `conda install pip` inside the environment to make sure you're using a local version of pip. – peastman Apr 04 '19 at 20:22
  • 1
    @sambeth OP is on macos. – Robino Feb 27 '20 at 14:07
  • ```python -m pip install package-name``` works. The problem is most of us installed conda and there are packages that only pip supports. You can either create virtual environments and carry your work, or run this command. – Suraj May 21 '21 at 13:37
  • Are we saying then that 1st run "conda install pip" and 2nd run "python -m pip install package-name"? Is this the agreed on best practice? – Geoffrey Anderson Jul 29 '21 at 18:39
  • peastman Apr 4 '19 at 20:22 is correct. You must install pip into your conda virtual environments and then run THAT version of pip to install pip packages into the conda virtual environment. – Rich Lysakowski PhD Aug 14 '21 at 04:36
  • You should first install the conda API into your new conda environment using "conda install conda", and then execute "pip install package-name" – Rich Lysakowski PhD Dec 28 '21 at 19:03
20

This is what worked for me (Refer to image linked)

  1. Open Anaconda
  2. Select Environments in the left hand pane below home
  3. Just to the right of where you selected and below the "search environments" bar, you should see base(root). Click on it
  4. A triangle pointing right should appear, click on it an select "open terminal"
  5. Use the regular pip install command here. There is no need to point to an environment/ path

For future reference, you can find the folder your packages are downloading to if you happen to have a requirement already satisfied. You can see it if you scroll up in the terminal. It should read something like: requirement already satisfied and then the path

[pip install anaconda]

giusti
  • 3,156
  • 3
  • 29
  • 44
11

If you didn't add pip when creating conda environment

conda create -n env_name pip

and also didn't install pip inside the environment

source activate env_name
conda install pip

then the only pip you got is the system pip, which will install packages globally.

Bus as you can see in this issue, even if you did either of the procedure mentioned above, the behavior of pip inside conda environment is still kind of undefined.

To ensure using the pip installed inside conda environment without having to type the lengthy /home/username/anaconda/envs/env_name/bin/pip, I wrote a shell function:

# Using pip to install packages inside conda environments.
cpip() {
    ERROR_MSG="Not in a conda environment."
    ERROR_MSG="$ERROR_MSG\nUse \`source activate ENV\`"
    ERROR_MSG="$ERROR_MSG to enter a conda environment."

    [ -z "$CONDA_DEFAULT_ENV" ] && echo "$ERROR_MSG" && return 1

    ERROR_MSG='Pip not installed in current conda environment.'
    ERROR_MSG="$ERROR_MSG\nUse \`conda install pip\`"
    ERROR_MSG="$ERROR_MSG to install pip in current conda environment."

    [ -e "$CONDA_PREFIX/bin/pip" ] || (echo "$ERROR_MSG" && return 2)

    PIP="$CONDA_PREFIX/bin/pip"
    "$PIP" "$@"
}

Hope this is helpful to you.

Allen Ye
  • 119
  • 1
  • 5
  • "If you didn't add pip when creating conda environment, and also didn't install pip inside the environment, then the only pip you got is the system pip, which will install packages globally." Pip can corrupt your base conda environment when you let it install anything into globally. Just don't do it. See https://www.anaconda.com/blog/using-pip-in-a-conda-environment for more information. – Rich Lysakowski PhD Oct 12 '21 at 07:51
10

python -m pip install Pillow

Will use pip of current Python activated with

source activate shrink_venv

intsco
  • 1,276
  • 12
  • 14
4

For those wishing to install a small number of packages in conda with pip then using,

sudo $(which pip) install <instert_package_name>

worked for me.

Explainaton

It seems, for me anyway, that which pip is very reliable for finding the conda env pip path to where you are. However, when using sudo, this seems to redirect paths or otherwise break this.

Using the $(which pip) executes this independently of the sudo or any of the commands and is akin to running /home/<username>/(mini)conda(3)/envs/<env_name>/pip in Linux. This is because $() is run separately and the text output added to the outer command.

Little Bobby Tables
  • 4,466
  • 4
  • 29
  • 46
4

All above answers are mainly based on use of virtualenv. I just have fresh installation of anaconda3 and don't have any virtualenv installed in it. So, I have found a better alternative to it without wondering about creating virtualenv.

If you have many pip and python version installed in linux, then first run below command to list all installed pip paths.

whereis pip

You will get something like this as output.

pip: /usr/bin/pip /home/prabhakar/anaconda3/bin/pip /usr/share/man/man1/pip.1.gz

Copy the path of pip which you want to use to install your package and paste it after sudo replacing /home/prabhakar/anaconda3/bin/pip in below command.

sudo /home/prabhakar/anaconda3/bin/pip install <package-name>

This worked pretty well for me. If you have any problem installing, please comment.

4

if you're using windows OS open Anaconda Prompt and type activate yourenvname

And if you're using mac or Linux OS open Terminal and type source activate yourenvname

yourenvname here is your desired environment in which you want to install pip package

after typing above command you must see that your environment name is changed from base to your typed environment yourenvname in console output (which means you're now in your desired environment context)

Then all you need to do is normal pip install command e.g pip install yourpackage

By doing so, the pip package will be installed in your Conda environment

Code_Worm
  • 4,069
  • 2
  • 30
  • 35
  • 1
    THIS POST SUGGESTS A VERY BAD IDEA: Do not use pip in a conda environment, unless you are "dead-ending it", meaning that you will use only pip in that environment from then onward, and will never install conda packages into that environment again. See this post for more information about why: https://www.anaconda.com/blog/using-pip-in-a-conda-environment – Rich Lysakowski PhD Oct 12 '21 at 07:55
4

I see a lot of good answers here, but I still wanted to share mine that worked for me, especially if you are switching from pip-era to conda-era. Following this, you can install any packages using both conda and pip.

Background

  • PIP - Python package manager only
  • Conda - Both package and environment manager for many languages, including Python

Install Pip by default every time you create a new conda environment

# install pip for your newly created environment
conda create -n my_new_env pip 

# activate your new conda environment
conda activate my_new_env

# now you can install any packages using both conda and pip
conda install package_name

#or
pip install package_name

This gives you the flexibility to install any packages in conda environment even if they are not available in conda (e.g. wordcloud)

conda activate my_new_env

# will not work as wordcloud is not available in conda
conda install wordcloud

# works fine
pip install wordcloud
Abu Shoeb
  • 4,747
  • 2
  • 40
  • 45
  • 1
    Great explanation. I have been using this approach `conda install pip` for several years and have not had any more problems with pip corrupting my base conda environment. – Rich Lysakowski PhD Apr 09 '23 at 05:57
3

I was facing a problem in installing a non conda package on anaconda, I followed the most liked answer here and it didn't go well (maybe because my anaconda is in F directory and env created was in C and bin folder was not created, I have no idea but it didn't work).

According to anaconda pip is already installed ( which is found using the command "conda list" on anaconda prompt), but pip packages were not getting installed so here is what I did, I installed pip again and then pip installed the package.

conda install pip
pip install see

see is a non-conda package.

Pieter
  • 895
  • 11
  • 22
Abhijeet sinha
  • 403
  • 4
  • 4
  • Do not use pip in a conda environment, unless you are "dead-ending it", meaning that you will use only pip in that environment from then onward, and will never install conda packages into that environment again. See this post for more information about why: anaconda.com/blog/using-pip-in-a-conda-environment – Rich Lysakowski PhD Oct 12 '21 at 07:57
3

Depends on how did you configure your PATH environmental variable. When your shell resolves the call to pip, which is the first bin it will find?

(test)$ whereis pip
pip: /home/borja/anaconda3/envs/test/bin/pip /home/borja/anaconda3/bin/pip

Make sure the bin folder from your anaconda installation is before /usr/lib (depending on how you did install pip). So an example:

(test) borja@xxxx:~$ pip install djangorestframework
....
Successfully installed asgiref-3.2.3 django-3.0.3 djangorestframework-3.11.0 pytz-2019.3 sqlparse-0.3.1

(test) borja@xxxx:~$ conda list | grep django
django                    3.0.3                    pypi_0    pypi
djangorestframework       3.11.0                   pypi_0    pypi

We can see the djangorestframework was installed in my test environment but if I check my base:

(base) borja@xxxx:~$ conda list | grep django

It is empty.

Personally I like to handle all my PATH configuration using .pam_environment, here an example:

(base) borja@xxxx:~$ cat .pam_environment
PATH DEFAULT=/home/@{PAM_USER}/anaconda3/bin:${PATH}

One extra commet. The way how you install pip might create issues:

  • You should use: conda install pip --> new packages installed with pip will be added to conda list.

  • You shodul NOT use: sudo apt install python3-pip --> new packages will not be added to conda list (so are not managed by conda) but you will still be able to use them (chance of conflict).

BorjaEst
  • 390
  • 2
  • 11
  • 1
    One extra commet. The way how you install pip might create issues: - You should use: conda install pip --> new packages installed with pip will be added to conda list. - You SHOULD not use: sudo apt install python3-pip --> new packages will not be added to conda list (so no managed) but you will still be able to use them (chance of conflict). – BorjaEst Mar 16 '20 at 14:53
  • hi everyone:) How can I remove a bin folder like `/usr/lib` in case that it is before my anaconda bin folder when running `whereis pip`? – Lenn Apr 28 '20 at 09:00
  • Try `sudo apt remove python3-pip` to remove pip from your linux distribution and then in the conda enviroment you are using: `conda install -c anaconda pip`. – BorjaEst May 13 '20 at 10:44
3

Well I tried all the above methods. None worked for me because of an issue with the proxy settings within the corporate environment. Luckily I could open the pypi website from the browser. In the end, the following worked for me:

  1. Activate your environment
  2. Download the .whl package manually from https://pypi.org/simple/<package_name>/
  3. Navigate to the folder where you have downloaded the .whl from the command line with your environment activated
  4. perform: pip install package_name_whatever.whl
MGLondon
  • 1,557
  • 15
  • 18
2

If you ONLY want to have a conda installation. Just remove all of the other python paths from your PATH variable.

Leaving only:

C:\ProgramData\Anaconda3
C:\ProgramData\Anaconda3\Scripts
C:\ProgramData\Anaconda3\Library\bin

This allows you to just use pip install * and it will install straight into your conda installation.

moto
  • 946
  • 10
  • 27
  • 1
    Do not use pip in a conda environment, unless you are "dead-ending it", meaning that you will use only pip in that environment from then onward, and will never install conda packages into that environment again. See this post for more information about why: anaconda.com/blog/using-pip-in-a-conda-environment – Rich Lysakowski PhD Oct 12 '21 at 07:58
2

Given the information described in this Anaconda blog post, I think the best practice would be to create an environment file so that your conda environments can be created predictably.

I tried a few of the answers posted here without success and I didn't feel like messing around with python paths etc. Instead, I added an environment.yml file similar to this:

name: your-environment-name
channels:
  - defaults
dependencies:
  - python=3.9.12
  - requests=2.28.1
  - pandas=1.4.4
  - pip=21.2.4
  - pip:
    - python-dotenv==0.19.2

This guarantees that you install all conda dependencies first, then install pip in the conda environment and use it to install dependencies that are unavailable through conda. This is predictable, reusable, and follows the advice described in the blog post.

You then create a new conda environment using the file with this command:

conda env create -f environment.yml
stelloprint
  • 303
  • 2
  • 9
1

I know the original question was about conda under MacOS. But I would like to share the experience I've had on Ubuntu 20.04.

In my case, the issue was due to an alias defined in ~/.bashrc: alias pip='/usr/bin/pip3'. That alias was taking precedence on everything else.

So for testing purposes I've removed the alias running unalias pip command. Then the corresponding pip of the active conda environment has been executed properly.

The same issue was applicable to python command.

Rocky
  • 31
  • 4
1

I've looked at this answer and many other answers for hours today and couldn't figure this out with 30 years programming experience.

I ran:

conda create -n myenv python=3.9
conda activate myenv

and could not use pip. However, in another environment such as myenv2, myenv3, myenv4 it worked.

I was obtaining the dreaded urllib3 httpsconnection error.

So thought it has to be a missing urllib3 error or something else. It turns out that it was much more sinister than that. Unfortunately it works in other environments and for me I thought that it was related to the fact I'm using Debian on Windows 10 with WSL2. The fix was simple:

rm -rf $HOME/.cache

The pip cache was mangled from a previous install of the same environment. Probably due to the fact I had run an update on conda base and done a distribution upgrade. Because I'm wanting to run a production system with apache2 using a WSGI environment with flask, I want to always have the same conda instance name. So this was a must fix!

Eamonn Kenny
  • 1,926
  • 18
  • 20
0

Uninstall the duplicated python installation. Just keep anaconda and create an env with the desired python version as specified here: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-python.html. Then your python and pip versions will change as you switch between envs.

Bruck Wubete
  • 141
  • 2
  • 5
0

I had the same issue when I was installing the packages using pip command in Anaconda environment. It was saying the package is already installed but it was not installed in the Anaconda environment instead in the system-wide packages. I face it when I was using the ssh connection to the server.

Here is the one line solution that works like magic:

$(which python) -m pip install <package-name>

There is no need to perform extra installations and settings the paths. By adding $(which python) -m before pip will work everything as per expectations.

Enjoy.

Syed Muhammad Asad
  • 208
  • 1
  • 2
  • 13
0

I tried to install pycorenlp with Anaconda Prompt. However, it did not work for me. So, I installed pip using conda install pip. Then I executed pip install pycorenlp, and it worked.

Hamed Baziyad
  • 1,954
  • 5
  • 27
  • 40
0

All you have to do is, activate you environment:

$ conda activate <env-name>

Then install pip, if pip or pip3 not found in the environment

$ conda install pip

Use pip or pip3 as

$ pip3 install <pkg-name>
DevLoverUmar
  • 11,809
  • 11
  • 68
  • 98