Hi, I just installed requests with pip but I can't import it

后端 未结 2 866
眼角桃花
眼角桃花 2021-01-29 02:44

For example my Code is:

import requests  
r = requests.get(\'https://www.python.org\')  
r.status_code  

And the Result is:



        
相关标签:
2条回答
  • 2021-01-29 02:54

    Well, as issue is that Requests require Python-3.3 or higher so you will need to upgrade your Python. I noticed you are on windows so follow this link to download the installer for latest stable Python-3.5.2 (https://www.python.org/ftp/python/3.5.2/python-3.5.2-webinstall.exe).

    Also, look into using virtualenvs(https://virtualenv.pypa.io/en/stable/). They are a great way to insulate the python packages you have installed and you can set it up using for different projects that may have different requirements.

    0 讨论(0)
  • 2021-01-29 03:05

    Requests requires Python 3.3 or newer. It doesn't work on Python 3.2 as that version doesn't support the required u'...' compatibility syntax for string literals.

    From the requests documentation:

    Requests officially supports Python 2.6–2.7 & 3.3–3.5, and runs great on PyPy.

    Note that 3.2 is rather.. ancient. You really want to upgrade to a more recent Python 3 revision.

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