no module named urllib.parse (How should I install it?)

后端 未结 11 578
青春惊慌失措
青春惊慌失措 2020-12-03 02:49

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 al

相关标签:
11条回答
  • 2020-12-03 03:10

    Manually include urllib.parse: https://docs.python.org/3.3/library/urllib.parse.html#module-urllib.parse

    0 讨论(0)
  • 2020-12-03 03:10
    pip install -U websocket 
    

    I just use this to fix my problem

    0 讨论(0)
  • 2020-12-03 03:11

    For Python 3, use the following:

    import urllib.parse
    
    0 讨论(0)
  • 2020-12-03 03:14

    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
    
    0 讨论(0)
  • 2020-12-03 03:15

    You want urlparse using python2:

    from urlparse import urlparse
    
    0 讨论(0)
提交回复
热议问题