Azure ML执行Python模块:禁用网络I / O?

时间:2015-03-27 09:44:40

标签: python azure azure-machine-learning-studio

无法从azure ml连接到URL并获取其内容

我的代码:

import requests
def azureml_main(dataframe1 = None, dataframe2 = None):    
    b= requests.get("http://www.google.com",timeout=30)
    dataframe1 = b.content
    return dataframe1

是否需要进行任何更改才能连接到网址

错误:

Error 0085: The following error occurred during script evaluation, please view the output log for more information:
 ---------- Start of error message from Python interpreter ----------
data:text/plain,Caught exception while executing function: Traceback (most recent call last):
File "C:\server\invokepy.py", line 167, in batch
odfs = mod.azureml_main(*idfs)
File "C:\temp\azuremod.py", line 24, in azureml_main
b= requests.get("http://www.google.com",timeout=30)
File "C:\pyhome\lib\site-packages\requests\api.py", line 55, in get
return request('get', url, **kwargs)
File "C:\pyhome\lib\site-packages\requests\api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "C:\pyhome\lib\site-packages\requests\sessions.py", line 456, in request
resp = self.send(prep, **send_kwargs)
File "C:\pyhome\lib\site-packages\requests\sessions.py", line 559, in send
r = adapter.send(request, **kwargs)
File "C:\pyhome\lib\site-packages\requests\adapters.py", line 375, in send
raise ConnectionError(e, request=request)
ConnectionError: HTTPConnectionPool(host='www.google.com', port=80): Max retries exceeded with url: / (Caused by <class 'socket.gaierror'>: [Errno 11001] getaddrinfo failed)

---------- End of error message from Python  interpreter  ---------

或者是否需要对天蓝色ml设置进行任何更改

1 个答案:

答案 0 :(得分:1)

更新 2016年1月28日

现在支持Execute Python Script的网络I / O.

过时

执行Python模块不支持网络I / O.为了执行这样的程序,您应该启动虚拟机(您可以选择Windows或Linux)。

视窗:

  1. RDP进入虚拟机
  2. 安装您选择的Python
  3. 您可以将Python程序从本地Windows计算机拖放到RDP屏幕上以传输代码
  4. 然后运行您的程序
  5. Ubuntu的:

    1. 使用Cygwin或Putty(Windows)或终端SSH(mac)ssh yourUserName@yourAzureVM.cloudapps.net
    2. 将SSH连接到虚拟机
    3. 安装Python sudo apt-get install python
    4. 打开首选的Linux文本编辑器vi myProgram.py
    5. 将代码复制并粘贴到编辑器中(将vi保留为esc :wq
    6. 运行代码python myProgram.py
    7. 要将数据从VM移动到AzureML,请查看Github上的Azure-MachineLearning-ClientLibrary-Python