이용형
이용형

Reputation: 529

error using pip search (pip search stopped working)

Error image

I am getting this error in pip search while studying python. The picture is an error when I pip search. Can you tell me how to fix it?

$ pip search pdbx
ERROR: Exception:
Traceback (most recent call last):                                                                                                                                                  
  File "*/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 224, in _main                                                
    status = self.run(options, args)                                                                                                                                                
  File "*/lib/python3.7/site-packages/pip/_internal/commands/search.py", line 62, in run                                                    
    pypi_hits = self.search(query, options)                                                                                                                                         
  File "*/lib/python3.7/site-packages/pip/_internal/commands/search.py", line 82, in search                                                 
    hits = pypi.search({'name': query, 'summary': query}, 'or')                                                                                                                     
  File "/usr/lib/python3.7/xmlrpc/client.py", line 1112, in __call__                                                                                                                
    return self.__send(self.__name, args)                                                                                                                                           
  File "/usr/lib/python3.7/xmlrpc/client.py", line 1452, in __request                                                                                                               
    verbose=self.__verbose                                                                                                                                                          
  File "*/lib/python3.7/site-packages/pip/_internal/network/xmlrpc.py", line 46, in request                                                 
    return self.parse_response(response.raw)                                                                                                                                        
  File "/usr/lib/python3.7/xmlrpc/client.py", line 1342, in parse_response                                                                                                          
    return u.close()                                                                                                                                                                
  File "/usr/lib/python3.7/xmlrpc/client.py", line 656, in close                                                                                                                    
    raise Fault(**self._stack[0])                                                                                                                                                   
xmlrpc.client.Fault: <Fault -32500: 'RuntimeError: This API has been temporarily disabled due to unmanageable load and will be deprecated in the near future. Please use the Simple or JSON API instead.'>              

Upvotes: 49

Views: 55837

Answers (4)

pippo1980
pippo1980

Reputation: 3096

The error says

Please use the Simple or JSON API instead

You can try pypi-simple to query the pip repository

https://pypi.org/project/pypi-simple/

It gives an example too, I tried to use it here:

pypi-simple version 0.8.0 DistributionPackage' object has no attribute 'get_digest':

!/usr/bin/env python3
 -*- coding: utf-8 -*-
"""
Created on Thu Nov  11 17:40:03 2020

@author: Pietro

"""


from pypi_simple import PyPISimple

def simple():
    package=input('\npackage to be checked ')
    
    try:
        with PyPISimple() as client:
            requests_page = client.get_project_page(package)
    
    except:
        print("\n SOMETHING WENT WRONG !!!!! \n\n",
        "CHECK INTERNET CONNECTION OR DON'T KNOW WHAT HAPPENED !!!\n")
        
    pkg = requests_page.packages[0]
    
    print(pkg)
    print(type(pkg))
    
    print('\n',pkg,'\n')

    print('\n'+pkg.filename+'\n')
    
    print('\n'+pkg.url+'\n')
    
    print('\n'+pkg.project+'\n')
    
    print('\n'+pkg.version+'\n')
    
    print('\n'+pkg.package_type+'\n')
    
    #print('\n'+pkg.get_digest()+'\n','ENDs HERE !!!!') #wasnt working
     

if __name__ == '__main__': 
  
   simple()

got -4 so far for this answer don't know why , figureout I can try to check for a package with:

# package_name = input('insert package name  :  ')

package_name = 'numpy'

import requests
url = ('https://pypi.org/pypi/'+package_name+'/json')
r = requests.get(url)


try: 
    data = r.json()
    
    for i in data:
        if i == 'info':
            print('ok')
            for j in data[i]:
                if j == 'name':
                    print((data[i])[j])
                    print([k for k in (data['releases'])])


    
except:
    print('something went south !!!!!!!!!!')

Upvotes: -4

Yunfei Tang
Yunfei Tang

Reputation: 606

search on website, https://pypi.org/, then install the package you wanted

Upvotes: -1

Chux Uzoeto
Chux Uzoeto

Reputation: 1404

The pip search command queries PyPI's servers, and PyPI's maintainers have explained that the API endpoint that the pip search command queries is very resource intensive and too expensive for them to always keep open to the public. Consequently they sometimes throttle access and are actually planning to remove it completely soon.

See this GitHub issues thread ...

The solution I am using for now is to pip install pip-search (a utility created by GitHub user @victorgarric).

So, instead of 'pip search', I use pip_search. Definitely beats searching PyPI via a web browser

Upvotes: 65

Karmavil
Karmavil

Reputation: 993

Follow the suggestion from JRK at the discussion at github (last comment) the search command is temporarily disabled, use your browser to search for packages meanwhile: Check the thread on github and give him a thumb up ;)

Upvotes: 20

Related Questions