aliyun / aliyun-odps-python-sdk

ODPS Python SDK and data analysis framework
http://pyodps.readthedocs.io
Apache License 2.0
434 stars 97 forks source link

在window10下执行reader.to_pandas()报错的临时解决方案 #165

Closed expyhist closed 2 years ago

expyhist commented 3 years ago

当你在win10下执行以下代码:

from odps import ODPS
instatnce = odps.execute_sql('select * from dual')
with instatnce.open_reader(tunnel=True) as reader:
    df = reader.to_pandas()
    print(df)

会报以下错误:

Traceback (most recent call last): File "C:/Users/yangh/PycharmProjects/fenxiang_project/auto_excute_sql.py", line 23, in df = reader.to_pandas() File "C:\Users\yangh\anaconda3\lib\site-packages\odps\models\instance.py", line 854, in to_pandas _mp_context = multiprocessing.get_context('fork') File "C:\Users\yangh\anaconda3\lib\multiprocessing\context.py", line 239, in get_context return super().get_context(method) File "C:\Users\yangh\anaconda3\lib\multiprocessing\context.py", line 193, in get_context raise ValueError('cannot find context for %r' % method) from None ValueError: cannot find context for 'fork'

临时解决方案:

_mp_context = multiprocessing.get_context('fork')

改成

_mp_context = multiprocessing.get_context('spwan')

原代码位置:

https://github.com/aliyun/aliyun-odps-python-sdk/blob/683e325e9848a8d30271939838e26ae05a9f6bff/odps/models/instance.py?_pjax=%23js-repo-pjax-container%2C%20div%5Bitemtype%3D%22http%3A%2F%2Fschema.org%2FSoftwareSourceCode%22%5D%20main%2C%20%5Bdata-pjax-container%5D#L854

hekaisheng commented 3 years ago

这是已知 bug,我们会在下个版本修复

aaadrain commented 2 years ago

我也遇到这个bug, 下一版本啥时候发布呀?

godosou commented 2 years ago

现在windows要用,是不是得修改源码安装?

expyhist commented 2 years ago

现在windows要用,是不是得修改源码安装?

对的,找到那个py文件,修改一下,就可以跑通了。

hekaisheng commented 2 years ago

新版本已经修复,可以验证下

wjsi commented 2 years ago

No response after fix submitted.