1. 程式人生 > >python error: curl: (1) Protocol "'https" not supported or disabled in libcurl

python error: curl: (1) Protocol "'https" not supported or disabled in libcurl

ubun 出現 lib 沒有 ror 但是 tput process 空格

python 調用curl訪問一個網頁時,出現error: curl: (1) Protocol "‘https" not supported or disabled in libcurl

控制臺直接curl xxx是ok的

output = subprocess.check_output(["curl","https://stackoverflow.com/questions/6884669/curl-1-protocol-https-not-supported-or-disabled-in-libcurl"]) # error
print(output)

這邊有一個解決方案,但是對此並沒有解決問題,原來是雙引號的問題,換成但引號就解決問題了,一直以為但引號雙引號都能表示字符串,具體為什麽還不是很清楚,但是能解決問題了,需要深入再去了解下,如知請告訴我下

output = subprocess.check_output(["curl",‘https://stackoverflow.com/questions/6884669/curl-1-protocol-https-not-supported-or-disabled-in-libcurl’]) # ok
print(output)

看demo也是單引號,curl支持但引號嗎? 測試了下 pycurl都支持 但引號雙引號一樣

import pycurl
c = pycurl.Curl()
c.setopt(c.URL, ‘https://www.taobao.com‘)
c.perform()

另外該error:

可能其他原因:

1、curl 不支持https 可以用curl -V 查看

對應解決方法是重新安裝curl 可參考:http://www.codeweblog.com/curl%e4%b8%8d%e6%94%af%e6%8c%81https%e5%8d%8f%e8%ae%ae%e9%97%ae%e9%a2%98%e8%a7%a3%e5%86%b3/

wget http://archive.ubuntu.com/ubuntu/pool/main/c/curl/curl_7.35.0.orig.tar.gz
tar -xzvf curl_7.35.0.orig.tar.gz
cd curl_7.35.0.orig
./configure
make
sudo make install

2、引號內有空格 “ https”

python error: curl: (1) Protocol "'https" not supported or disabled in libcurl