Having "urllib.error.URLError: <urlopen error unknown url type: https>" error when trying to automate script, but works fine running inside Spyder
Having "urllib.error.URLError: <urlopen error unknown url type: https>" error when trying to automate script, but works fine running inside Spyder
所以我有一个脚本可以从某些网站读取表格。
当我 运行 这个脚本在 Python IDE 中时,它工作得很好。如果我尝试 运行 它作为一个批处理文件独立,它不起作用。它反映了以下错误:
urllib.error.URLError:
关于什么可能导致它的任何想法?我的剧本真的很短:
# -*- coding: utf-8 -*-
"""
Created on Sun Aug 18 20:24:04 2019
@author: blueb
"""
import requests
import numpy as np
import pandas as pd
dfs = pd.read_html("https://www.nea.gov.sg/dengue-zika/dengue/dengue-clusters")
count = 0
for df in dfs:
count += 1
print(df.head())
clusters_info = dfs[1]
clusters_info.to_csv('clusters.csv')
dls = "https://www.moh.gov.sg/docs/librariesprovider5/diseases-updates/weekly-infectious-bulletin_caseswk32y2019.xlsx?sfvrsn=cceaba67_0"
resp = requests.get(dls)
output = open('denguetrends.xlsx', 'wb')
output.write(resp.content)
output.close()
trends = pd.read_excel('denguetrends.xlsx')
trends.to_csv('denguetrends.csv')
如果此页面支持,请使用 http
解决方法。真正的问题是 Python 在环境中的安装 [broken SSL
]:
您是否构建了发生这种情况的 Python 环境?还是预先打包好的?
>>> import ssl
ImportError: No module named ssl
在任何情况下,您的 Spyder
安装所使用的 Python 解释器未在适当的 SSL
支持下编译,或者与您系统的 SSL
.确保在安装 Spyder
之前安装 SSL
。这些资源可以为您提供帮助:
-
Building Python with SSL support in non-standard location
https://techglimpse.com/install-python-openssl-support-tutorial/
所以我有一个脚本可以从某些网站读取表格。
当我 运行 这个脚本在 Python IDE 中时,它工作得很好。如果我尝试 运行 它作为一个批处理文件独立,它不起作用。它反映了以下错误: urllib.error.URLError:
关于什么可能导致它的任何想法?我的剧本真的很短:
# -*- coding: utf-8 -*-
"""
Created on Sun Aug 18 20:24:04 2019
@author: blueb
"""
import requests
import numpy as np
import pandas as pd
dfs = pd.read_html("https://www.nea.gov.sg/dengue-zika/dengue/dengue-clusters")
count = 0
for df in dfs:
count += 1
print(df.head())
clusters_info = dfs[1]
clusters_info.to_csv('clusters.csv')
dls = "https://www.moh.gov.sg/docs/librariesprovider5/diseases-updates/weekly-infectious-bulletin_caseswk32y2019.xlsx?sfvrsn=cceaba67_0"
resp = requests.get(dls)
output = open('denguetrends.xlsx', 'wb')
output.write(resp.content)
output.close()
trends = pd.read_excel('denguetrends.xlsx')
trends.to_csv('denguetrends.csv')
如果此页面支持,请使用 http
解决方法。真正的问题是 Python 在环境中的安装 [broken SSL
]:
您是否构建了发生这种情况的 Python 环境?还是预先打包好的?
>>> import ssl
ImportError: No module named ssl
在任何情况下,您的 Spyder
安装所使用的 Python 解释器未在适当的 SSL
支持下编译,或者与您系统的 SSL
.确保在安装 Spyder
之前安装 SSL
。这些资源可以为您提供帮助:
-
Building Python with SSL support in non-standard location
https://techglimpse.com/install-python-openssl-support-tutorial/