MacOS resolves "Import requests No module named requests"

Source: Internet
Author: User

MacOS resolves "Import requests No module named requests"

  1. System Information
    sw_versProductName:    Mac OS XProductVersion: 10.12.2BuildVersion:   16C67
  2. Test scripts
    #内容如下:cat test.py #!/usr/bin/env pythonimport requestsbaidu_request = requests.get(‘http://www.baidu.com‘)print baidu_request.text
  3. Error message
    #执行脚本python ./test.py#报错信息如下:“import requests No module named requests”
  4. workaround
    Cause: Requests Library
      is not installed by default on Mac OSX #安装pipsudo easyinstall pip as Error: Download error on https:// pypi.python.org/simple/pip/: [ssl:tlsv1_alert_protocol_version] TLSv1 ALERT PROTOCOL VERSION (_ssl.c:590)--Some Packages May is not found! Couldn ' t find index page for ' Pip ' (maybe misspelled?)  
      #处理pip安装报错curl ' https://bootstrap.pypa.io/get-pip.py ' > Get-pip.pysudo python get-pip.py  
      #安装requests库sudo pip install requests  
      #ok现在可以正常执行test. Pypython test.py <! DOCTYPE html><!--STATUS ok-->

MacOS resolves import requests No module named requests "

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.