我提供以下步骤,以展示如何更新Execute Python Script中的pandas库版本。
第一步:使用virtualenv组件在你的系统中创建一个独立的python运行环境。如果不安装,请先用命令pip install virtualenv安装。没有。
如果你安装成功,你可以在你的 python/Scripts 文件中看到它。
Step2:运行命令创建独立的python运行环境。
第三步:然后进入创建目录的Scripts文件夹并激活它(这一步很重要,不要错过)
请不要关闭此命令窗口并在此命令窗口中使用pip install pandas==0.19 下载外部库。
第 4 步:将 Lib/site-packages 文件夹中的所有文件压缩成一个 zip 包(我称之为 pandas - 包在这里)
第 5 步:将 zip 包上传到 Azure Machine Learning WorkSpace DataSet。
具体步骤请参考Technical Notes。
成功后会在DataSet List中看到上传的包
第六步:在Execute Python Script模块定义方法azureml_main之前,需要先移除旧的pandas模块及其依赖,然后再次导入pandas,如下代码。
import sys
import pandas as pd
print(pd.__version__)
del sys.modules['pandas']
del sys.modules['numpy']
del sys.modules['pytz']
del sys.modules['six']
del sys.modules['dateutil']
sys.path.insert(0, '.\\Script Bundle')
for td in [m for m in sys.modules if m.startswith('pandas.') or m.startswith('numpy.') or m.startswith('pytz.') or m.startswith('dateutil.') or m.startswith('six.')]:
del sys.modules[td]
import pandas as pd
print(pd.__version__)
# The entry point function can contain up to two input arguments:
# Param<dataframe1>: a pandas.DataFrame
# Param<dataframe2>: a pandas.DataFrame
def azureml_main(dataframe1 = None, dataframe2 = None):
然后你可以从日志中看到结果如下,首先打印旧版本0.14.0,然后从上传的zip文件中打印新版本0.19.0。
[Information] 0.14.0
[Information] 0.19.0
您也可以参考这些帖子:Access blob file using time stamp in Azure 和 reload with reset。
希望对你有所帮助。