簡體   English   中英

如何從用戶定義的包,Python導入ipyparallel函數

[英]How to import ipyparallel function from user defined package, Python

我有一個python腳本,其中包含許多用戶定義的函數,這些函數已在本地設置為as包。 我可以運行input_processing.py腳本中的所有功能,但我打算並行運行的功能除外。

這是導入包的代碼...

import attrition25.input_processing as attrition

我收到此錯誤...

NameError: name 'dview' is not defined

這就是input.processing.py ...中的函數外觀

@dview.parallel(block=True)
def get_dmat_elements(a, b, c):
    d = a + b + c
    return(d)

我嘗試了sync_imports()並查看了@interactive裝飾器,但我什么也沒找到。 任何幫助,將不勝感激。

盡管我沒有完全了解范圍,但為了使函數正常工作,我不得不將其添加到input_processing.py腳本的開頭...

import ipyparallel as ipp
# Create directView Instance for Parallel Processing
c = ipp.Client()
dview = c[:] # use all engines

我在進行測試的Jupyter Notebook中具有完全相同的代碼塊,但這沒有用。

希望這可以幫助某個人。

干杯!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM