I'm trying to run a REST API on CentOS 7, I read urllib.parse is in Python 3 but I'm using Python 2.7.5 so I don't know how to install this module.
I installed all the requirements but still can't run the project.
When I'm looking for a URL I get this (I'm using the browsable interface):
Output:
ImportError at /stamp/ No module named urllib.parse
parse — Parse URLs into components in Python. This module provides a standard interface to break Uniform Resource Locator (URL) strings in components or to combine the components back into a URL string. It also has functions to convert a "relative URL" to an absolute URL given a "base URL."
The urllib module in Python 3 allows you access websites via your program. This opens up as many doors for your programs as the internet opens up for you. urllib in Python 3 is slightly different than urllib2 in Python 2, but they are mostly the same.
Source code: Lib/urllib/parse.py. This module defines a standard interface to break Uniform Resource Locator (URL) strings up in components (addressing scheme, network location, path etc.), to combine the components back into a URL string, and to convert a “relative URL” to an absolute URL given a “base URL.”
If you need to write code which is Python2 and Python3 compatible you can use the following import
try: from urllib.parse import urlparse except ImportError: from urlparse import urlparse
You want urlparse using python2:
from urlparse import urlparse
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With