18

I would like to import urllib to use the function 'request'. However, I encountered an error when trying to download via Pycharm:

"Could not find a version that satisfies the requirement urllib (from versions: ) No matching distribution found for urllib"

I tried pip install urllib but still had the same error. I am using Python 2.7.11. Really appreciate any help

2
  • 5
    urllib is in the standard lib. It should be included and you don't need to install it. import urllib works for me. Though, requests is an entirely different library you can install. Oct 14, 2016 at 19:26
  • 1
    I think he meant urllib.requests (in python 3 the namespaces have been redone). Oct 14, 2016 at 19:28

1 Answer 1

30

A few things:

  1. As metioned in the comments, urllib is not installed through pip, it is part of the standard library, so you can just do import urllib without installation.
  2. Python 3.x has a urllib.request module, but Python 2.x does not, as far as I know.
  3. The functionality that you are looking for from urllib.request is most likely contained in urllib2 (which is also part of the standard library), but you might be even better off using requests, which probably does need to be installed through pip in your case:

    pip install requests
    

    In fact, the urllib2 documentation itself recommends that you use the requests library "for a higher-level HTTP client interface" - but I am not sure what you wish to do, so it is hard to say what would be best for your particular use case.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.