将代理传递给 Seaborn [英] Pass proxy to Seaborn
问题描述
我使用 seaborn
进行数据可视化.但它失败了它在文档中的样本数据
I am using seaborn
for data visualization. But it fails over the sample data it has in documentation
import seaborn as sns
sns.set()
tips = sns.load_dataset("tips")
Traceback (most recent call last):
File "databaseConnection.py", line 35, in <module>
tips = sns.load_dataset("tips")
File "C:\python3.7\lib\site-packages\seaborn\utils.py", line 428, in load_dataset
urlretrieve(full_path, cache_path)
File "C:\python3.7\lib\urllib\request.py", line 247, in urlretrieve
with contextlib.closing(urlopen(url, data)) as fp:
File "C:\python3.7\lib\urllib\request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "C:\python3.7\lib\urllib\request.py", line 525, in open
response = self._open(req, data)
File "C:\python3.7\lib\urllib\request.py", line 543, in _open
'_open', req)
File "C:\python3.7\lib\urllib\request.py", line 503, in _call_chain
result = func(*args)
File "C:\python3.7\lib\urllib\request.py", line 1360, in https_open
context=self._context, check_hostname=self._check_hostname)
File "C:\python3.7\lib\urllib\request.py", line 1319, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 11001] getaddrinfo failed>
那是因为我在代理后面,但我如何要求 seaborn
使用代理?
That's because I am behind a proxy, but how can I ask seaborn
to use proxy?
推荐答案
您可以手动下载文件.
使用
import seaborn as sns
print(sns.utils.get_data_home())
找出您的 seaborn 数据的文件夹,例如它可能在 Windows 上显示为 C:\Users\username\seaborn-data
.
to find out the folder for your seaborn data, e.g. it might come out as C:\Users\username\seaborn-data
on windows.
将文件 https://raw.githubusercontent.com/mwaskom/seaborn-data/master/tips.csv
下载到该文件夹.最后,使用缓存"选项
Download the file https://raw.githubusercontent.com/mwaskom/seaborn-data/master/tips.csv
to that folder. Finally, use the "cached" option
sns.load_dataset("tips", cache=True)
或者将文件下载到任何其他文件夹.使用该文件夹的路径名作为 data_home
参数
Alternatively download the file to any other folder. Use that folder's pathname as data_home
argument
sns.load_dataset(name, cache=True, data_home="path/to/folder")
这篇关于将代理传递给 Seaborn的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!