首页 > 解决方案 > 在 Azure ML Studio 中更新 pandas 会导致错误

问题描述

此问题基于用户 user4446237 提出的另一个问题的解决方案:Updating pandas to version 0.19 in Azure ML Studio

我已按照答案中提供的步骤进行操作,最后我还得到了信息,即我导入了新版本的熊猫(0.23.3)而不是熊猫(0.18.0)。但是,在检索包的版本后,代码会遇到错误:

Caught exception while executing function: Traceback (most recent call last):
  File "C:\server\invokepy.py", line 192, in batch
    idfs = [parameter for infile in infiles
  File "C:\server\invokepy.py", line 194, in <listcomp>
    infile, is_buffer=False)]
  File "C:\server\XDRReader\xdrutils.py", line 47, in XDRToPyObjects
    return XDRBridge.xdr_to_py_positional(attrList)
  File "C:\server\XDRReader\xdrbridge.py", line 216, in xdr_to_py_positional
    retList.append(XDRBridge.xdrobject_to_dataframe(key, value))
  File "C:\server\XDRReader\xdrbridge.py", line 155, in xdrobject_to_dataframe
    }, index=np.arange(len(columns[0].values())), copy=False)
  File "C:\pyhome\lib\site-packages\pandas\core\frame.py", line 223, in __init__
    mgr = self._init_dict(data, index, columns, dtype=dtype)
  File "C:\pyhome\lib\site-packages\pandas\core\frame.py", line 356, in _init_dict
    columns = data_names = Index(keys)
  File "C:\pyhome\lib\site-packages\pandas\indexes\base.py", line 129, in __new__
    from .range import RangeIndex
SystemError: Parent module 'pandas.indexes' not loaded, cannot perform relative import

我使用的代码与 Jay Gong 的代码几乎相同:

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):

对于这个问题我能做些什么,或者我是否达到了 Azure ML Studio 的 Python 脚本模块的限制。

标签: pythonpandasazureanacondaazure-machine-learning-studio

解决方案


推荐阅读