43

Recently I needed to install PyPdf2 to one of my programs using Anaconda. Unfortunately, I failed, but the URLs that was added to Anaconda environment prohibit the updates of all the Conda libraries. Every time I tried to update anaconda it gives the following

conda update conda
Using Anaconda Cloud api site https://api.anaconda.org
Fetching package metadata ..........Error: Invalid index file: https://pypi.python.org/pypi/PyPDF2/1.26.0/win-64/repodata.json: No JSON object could be decoded

I typed the command conda info to see what causes the error, I found lots of URLs that points to PyPdf2!

Simply, I want to remove all these URLS from anaconda's channel URLs, How can I do it? No matter manually or automatic.

Note: I have uninstalled Anaconda, and reinstall, but no luck!

C:\WINDOWS\system32>conda info
Using Anaconda Cloud api site https://api.anaconda.org
Current conda install:

             platform : win-64
        conda version : 4.1.6
    conda-env version : 2.5.1
  conda-build version : 1.21.3
       python version : 2.7.12.final.0
     requests version : 2.10.0
     root environment : C:\Anaconda2  (writable)
  default environment : C:\Anaconda2
     envs directories : C:\Anaconda2\envs
        package cache : C:\Anaconda2\pkgs
         channel URLs : https://pypi.python.org/pypi/PyPDF2/1.26.0/win-64/
                        https://pypi.python.org/pypi/PyPDF2/1.26.0/noarch/
                        https://conda.anaconda.org/C:\Python27\Lib\site-packages\PyPDF2/win-64/
                        https://conda.anaconda.org/C:\Python27\Lib\site-packages\PyPDF2/noarch/
                        https://conda.anaconda.org/X:\Downloads\Compressed\PyPDF2-master\/win-64/
                        https://conda.anaconda.org/X:\Downloads\Compressed\PyPDF2-master\/noarch/
                        https://github.com/mstamy2/PyPDF2/zipball/master/win-64/
                        https://github.com/mstamy2/PyPDF2/zipball/master/noarch/
                        https://pypi.python.org/pypi/PyPDF2/win-64/
                        https://pypi.python.org/pypi/PyPDF2/noarch/
                        https://pythonhosted.org/PyPDF2/win-64/
                        https://pythonhosted.org/PyPDF2/noarch/
                        https://github.com/mstamy2/PyPDF2/win-64/
                        https://github.com/mstamy2/PyPDF2/noarch/
                        https://repo.continuum.io/pkgs/free/win-64/
                        https://repo.continuum.io/pkgs/free/noarch/
                        https://repo.continuum.io/pkgs/pro/win-64/
                        https://repo.continuum.io/pkgs/pro/noarch/
          config file : C:\Users\Dr. Mohammad Elnesr\.condarc
         offline mode : False
    is foreign system : False
Mohammad ElNesr
  • 2,477
  • 4
  • 27
  • 44

6 Answers6

43

Expanding upon Mohammed's answer.

All those URLs that you see in your conda info are your channel URLs. These are where conda will look for packages. As noted by @cel, these channels can be found in the .condarc file in your home directory.

You can interact with the channels, and other data, in your .condarc file with the conda config command. For example, let's say your .condarc file lists the following channels:

channels:
  - https://github.com/mstamy2/PyPDF2/  
  - defaults

Then if we do conda config --get channels we will see returned:

--add channels 'defaults'   # lowest priority
--add channels 'https://github.com/mstamy2/PyPDF2/'   # highest priority

If we then want to remove the github channel we would do conda config --remove channels 'https://github.com/mstamy2/PyPDF2/'. You can also add channels through the --add command so, for example, we could add back that channel with conda config --add channels 'https://github.com/mstamy2/PyPDF2/'.

In this case, since there were several channels to remove, it was probably faster to simply edit the .condarc directly but it's useful to know how to do it through conda config.

Community
  • 1
  • 1
Paul
  • 5,473
  • 1
  • 30
  • 37
  • You might want to update the URLs as PyPDF2 officially moved to https://github.com/py-pdf/PyPDF2 (I'm the new maintainer) – Martin Thoma May 01 '22 at 12:59
26

Fortunately, I found the answer (Thanks to @cel as well).

I navigated to C:\Users\{MyUserName}\ Then I found a file with no name but has a strange extension (.condarc) I opened it with Notepad++, I found the files as below>

enter image description here

Then I deleted all lines except the last one, saved the file, then I ran the command conda update conda, and it works without errors.

Mohammad ElNesr
  • 2,477
  • 4
  • 27
  • 44
  • 7
    This definitely works. You can also use `conda config` to manage your channels. For instance, use `conda config --get channels` to list your channels and use `conda config --remove channels 'X'` to remove channel `X`. – Paul Sep 19 '16 at 14:09
  • 3
    Thanks @Paul Why don't you add it as an answer to mark it as Accepted? – Mohammad ElNesr Sep 20 '16 at 06:33
  • I was not able to remove the channel using conda config --remove channels. I had to remove it from .condarc file. – samra irshad Aug 15 '20 at 01:38
16

Hopefully my answer helps someone else out there using Mac OS terminal. I accidentally added "new_channel" to my channels list and could not figure out how to remove it. I also could not find the .condarc file (maybe someone will enlighten me please) but I was able to use the terminal to complete this.

There's two types of "channels" in Conda. One is the channels and one is the channel URLs. If you're trying to delete the the channel URL, you cannot delete it using:

conda config --remove channels

Originally I typed conda info and saw the following:

channel URLs :

         https://repo.anaconda.com/pkgs/pro/osx-64
         https://repo.anaconda.com/pkgs/pro/noarch
         https://conda.anaconda.org/new_channel/osx-64
         https://conda.anaconda.org/new_channel/noarch

So I was thinking, ok, let me just type in the following.

conda config --remove channels https://conda.anaconda.org/new_channel/osx-64

THIS DOES NOT WORK.

What you have to do is type in the following:

conda config --show channels

You will see your channels:

channels:

  • defaults

  • new_channel

Now you know what your channel is called. It's called new_channel (may seem obvious, but sometimes not to us beginners).

So you type in:

conda config --remove channels new_channel

And boom, all the new_channel URLs are gone.

In OP's case, his channel was most likely called PyPdf2

So the correct code to type into Terminal is:

conda config --remove channels PyPdf2

AGAIN, DON'T TRY TO DELETE THE CHANNEL URL. MAKE SURE YOU DELETE THE CHANNEL ITSELF.

Lionel Yu
  • 328
  • 3
  • 11
  • In my case only the `defaults` channel is listed, but when I try to install a conda package conda will start "solving environment" forever... – Redoman Aug 22 '22 at 02:32
0

You can override the old URL wit the new one by simply executing the command below:

conda install --override-channels -c https://repo.anaconda.com/pkgs/main/win-64/ beautifulsoup4-4.6.0 Fetching package metadata .....

then there will be a question asking to proceed for installing the updated packages, y is the answer and when finished you can check out the changes by executing "conda info" which will show you the current path.

msbeigi
  • 189
  • 1
  • 5
0

For stubborn channel removals you can manually remove the channel from the .condarc file. To list .condarc files used by your environment type in the command conda info and look for keys populated config files and user config file. see conda info documentation for additional details.

0

Run the following command, swapping "channel-name-here" with the name of your channel:

conda config --remove channels channel-name-here

If you're unsure of your channel name, list all channels:

conda config --show channels

returns a list, including each channel name

  - defaults   
  - remove-me 
  - conda-forge
Liam Laverty
  • 152
  • 2
  • 9