Python urllib.request 在 Azure Notebooks 中抛出 403 [英] Python urllib.request Throws 403 in Azure Notebooks

查看:22
本文介绍了Python urllib.request 在 Azure Notebooks 中抛出 403的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图在 Azure Notebooks 中获取 TensorFlow 对象检测 API 模型,但我尝试的一切都给出了 403 Forbidden.在本地或 AWS 上检索文件没有问题.

Trying to acquire the TensorFlow Object Detection API models in a Azure Notebooks but everything I try gives 403 Forbidden. No problems retrieving the files locally or on AWS.

import six.moves.urllib as urllib
url = 'http://download.tensorflow.org/models/object_detection/rfcn_resnet101_coco_11_06_2017.tar.gz'
opener = urllib.request.URLopener()
opener.retrieve(url)

我尝试将 User-Agent 数据添加到标头等,但失败了.尝试使用 wget 并且也给出了 403.我认为笔记本在 docker 容器中运行,所以可能存在一些问题.任何见解或解决方法将不胜感激.

I tried adding User-Agent data to the header etc but that failed. Tried using wget and that gave a 403 also. I think the notebooks run in a docker container so maybe some issue there. Any insight or work-arounds would be much appreciated.

推荐答案

Azure Notebooks 有意限制对外部 URL 的访问.这最有可能阻止人们使用 Notebooks 服务对其他站点进行拒绝服务攻击.

Azure Notebooks intentionally restricts access to external URLs. This is most likely to prevent people from using the Notebooks service to perform denial of service attacks to other sites.

https://blogs.technet.microsoft.com/machinelearning/2016/03/30/jupyter-notebooks-with-r-in-azure-ml-studio-2/

对外部互联网站点的访问受到限制.但是,我们已将一些重要网址列入白名单:

Access to external internet sites is restricted. However, we have white listed a number of important URLs:

  • 所有 CRAN 镜像都在白名单中,因此您应该能够使用您最喜欢的 CRAN 镜像安装软件包.
  • Github 也被列入白名单,这意味着您可以使用 devtools::install_github() 安装不在 CRAN 上的软件包,或获取软件包的开发版本.

这篇关于Python urllib.request 在 Azure Notebooks 中抛出 403的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆