在 SageMath 中运行时使用 Dask 会抛出 ImportError

2023-12-31

最近,我一直在尝试使用 Dask 并行化一些 Sage(运行 OSX 11.2.3 的 MacBook Pro 上的 Sage 9.4)代码。我遇到的问题是,虽然我可以在 Sage 中运行 Dask,但每当我包含任何非“纯 python”代码时,它就会中断。特别是,它不断抛出 ImportError。这是我遇到的一个基本示例

import time
from dask import delayed
from dask.distributed import Client
from time import sleep

client = Client(n_workers=4)

def Hello():
    1+1 #this line breaks things by adding a sage operation
    #if I remove it the code runs fine
    return 'Hello World'

z = delayed(Hello)()
z.compute()

这段代码抛出以下错误

追溯

ImportError                               Traceback (most recent call last)
<timed eval> in <module>

~/.sage/local/lib/python3.9/site-packages/dask/base.py in compute(self, **kwargs)
    284         dask.base.compute
    285         """
--> 286         (result,) = compute(self, traverse=False, **kwargs)
    287         return result
    288 

~/.sage/local/lib/python3.9/site-packages/dask/base.py in compute(*args, **kwargs)
    566         postcomputes.append(x.__dask_postcompute__())
    567 
--> 568     results = schedule(dsk, keys, **kwargs)
    569     return repack([f(r, *a) for r, (f, a) in zip(results, postcomputes)])
    570 

~/.sage/local/lib/python3.9/site-packages/distributed/client.py in get(self, dsk, keys, workers, allow_other_workers, resources, sync, asynchronous, direct, retries, priority, fifo_timeout, actors, **kwargs)
   2669                     should_rejoin = False
   2670             try:
-> 2671                 results = self.gather(packed, asynchronous=asynchronous, direct=direct)
   2672             finally:
   2673                 for f in futures.values():

~/.sage/local/lib/python3.9/site-packages/distributed/client.py in gather(self, futures, errors, direct, asynchronous)
   1946             else:
   1947                 local_worker = None
-> 1948             return self.sync(
   1949                 self._gather,
   1950                 futures,

~/.sage/local/lib/python3.9/site-packages/distributed/client.py in sync(self, func, asynchronous, callback_timeout, *args, **kwargs)
    843             return future
    844         else:
--> 845             return sync(
    846                 self.loop, func, *args, callback_timeout=callback_timeout, **kwargs
    847             )

~/.sage/local/lib/python3.9/site-packages/distributed/utils.py in sync(loop, func, callback_timeout, *args, **kwargs)
    324     if error[0]:
    325         typ, exc, tb = error[0]
--> 326         raise exc.with_traceback(tb)
    327     else:
    328         return result[0]

~/.sage/local/lib/python3.9/site-packages/distributed/utils.py in f()
    307             if callback_timeout is not None:
    308                 future = asyncio.wait_for(future, callback_timeout)
--> 309             result[0] = yield future
    310         except Exception:
    311             error[0] = sys.exc_info()

/var/tmp/sage-9.4-current/local/lib/python3.9/site-packages/tornado/gen.py in run(self)
    733 
    734                     try:
--> 735                         value = future.result()
    736                     except Exception:
    737                         exc_info = sys.exc_info()

~/.sage/local/lib/python3.9/site-packages/distributed/client.py in _gather(self, futures, errors, direct, local_worker)
   1811                             exc = CancelledError(key)
   1812                         else:
-> 1813                             raise exception.with_traceback(traceback)
   1814                         raise exc
   1815                     if errors == "skip":

~/.sage/local/lib/python3.9/site-packages/distributed/protocol/pickle.py in loads()
     73             return pickle.loads(x, buffers=buffers)
     74         else:
---> 75             return pickle.loads(x)
     76     except Exception:
     77         logger.info("Failed to deserialize %s", x[:10000], exc_info=True)

/var/tmp/sage-9.4-current/local/lib/python3.9/site-packages/sage/rings/integer.pyx in init sage.rings.integer (build/cythonized/sage/rings/integer.c:54201)()
----> 1 r"""
      2 Elements of the ring `\ZZ` of integers
      3 
      4 Sage has highly optimized and extensive functionality for arithmetic with integers
      5 and the ring of integers.

/var/tmp/sage-9.4-current/local/lib/python3.9/site-packages/sage/rings/rational.pyx in init sage.rings.rational (build/cythonized/sage/rings/rational.cpp:40442)()
     98 
     99 
--> 100 import sage.rings.real_mpfr
    101 import sage.rings.real_double
    102 from libc.stdint cimport uint64_t

/var/tmp/sage-9.4-current/local/lib/python3.9/site-packages/sage/rings/real_mpfr.pyx in init sage.rings.real_mpfr (build/cythonized/sage/rings/real_mpfr.c:46795)()
----> 1 r"""
      2 Arbitrary Precision Real Numbers
      3 
      4 AUTHORS:
      5 

/var/tmp/sage-9.4-current/local/lib/python3.9/site-packages/sage/libs/mpmath/utils.pyx in init sage.libs.mpmath.utils (build/cythonized/sage/libs/mpmath/utils.c:9062)()
----> 1 """
      2 Utilities for Sage-mpmath interaction
      3 
      4 Also patches some mpmath functions for speed
      5 """

/var/tmp/sage-9.4-current/local/lib/python3.9/site-packages/sage/rings/complex_mpfr.pyx in init sage.rings.complex_mpfr (build/cythonized/sage/rings/complex_mpfr.c:34594)()
----> 1 """
      2 Arbitrary Precision Floating Point Complex Numbers
      3 
      4 AUTHORS:
      5 

/var/tmp/sage-9.4-current/local/lib/python3.9/site-packages/sage/rings/complex_double.pyx in init sage.rings.complex_double (build/cythonized/sage/rings/complex_double.c:25284)()
     96 from cypari2.convert cimport new_gen_from_double, new_t_COMPLEX_from_double
     97 
---> 98 from . import complex_mpfr
     99 
    100 from .complex_mpfr import ComplexField

ImportError: cannot import name complex_mpfr


我唯一一次看到像这样的 ImportError 是当我在 python 中运行 sage 并且没有包含from sage.all import *,所以我想知道 Dask 是否正在尝试在 python 中运行我的代码。我也不确定这是否属于 Sage 问题或 Dask 问题。任何帮助将不胜感激!


None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 SageMath 中运行时使用 Dask 会抛出 ImportError 的相关文章

随机推荐

  • SymEnumSymbols 返回 ERROR_SUCCESS 但没有给出结果

    我正在尝试从已加载的 DLL 中枚举符号 对于那些有兴趣的人来说 这是CPC覆盖项目 https github com atlaste CPPCoverage 对于某些功能我需要符号数据 问题分解 当进程启动或加载 DLL 时 需要为已计划
  • 如何在自动布局中使用约束标识符以及如何使用标识符更改约束? [迅速]

    当我在 Xcode 7 中编辑约束时 我发现标识符Interface Builder 中的字段 约束的标识符是什么 如何使用它 使用标识符我可以以编程方式访问约束并更改常量吗 我的问题是该标识符为什么有帮助以及有何帮助 有没有办法通过在子视
  • 如何使用带有空格键的 Bootstrap Tags 输入插件提交标签?

    我正在构建一个带有字段的表单 该字段使用Bootstrap标签输入插件 http timschlechter github io bootstrap tagsinput examples 一旦用户单击该插件 该插件就会输入一个标签Enter
  • 获取列表中函数的名称

    我希望实现什么 所以我想在函数列表中获取函数的名称 这是一个例子 foo list foo1 sum foo2 mean 我想从中提取什么foo is list sum mean 我希望它是一个函数 意思是 gt foo list foo1
  • 使用反射从dll调用方法后获取返回值

    我正在使用反射加载 dll 并尝试调用返回List
  • TPL DataFlow处理异常的正确方法

    我在使用 TPL DataFlow 管理队列 数据库 并将工作重定向到网格计算服务的 Windows 服务中遇到问题 在某一时刻 BufferBlock 停止释放任务 我不知道为什么 我认为这是因为在执行某些任务期间发生了一些异常 但它们被
  • Laravel 基本 HTTP 身份验证检查返回 False

    我使用 Laravel 中提供的基本 HTTP 身份验证来登录我的网站 然而 当我打电话时Auth Check 我总是得到false即使我已登录 也会得到响应 Does Auth Check 不适用于基本身份验证模型 如果不能 是否有任何方
  • 函数返回 Ajax 响应 - 值未定义? jQuery Ajax [重复]

    这个问题在这里已经有答案了 当我警告 jsonServerResponse 函数返回的值时 它的值是未定义的 尽管 JSON 是从 process php 页面返回的 function jsonServerResponse operatio
  • nginx:access.log 和 error.log 文件为空

    我刚刚使用命令在 Ubuntu 14 04 上安装了 nginx sudo apt get install nginx 现在 当我打开浏览器并输入地址时localhost然后我正确地显示了 欢迎来到 nginx 页面 另外 我检查了位于的配
  • Firebase 数据库未找到类错误 (NoClassDefFoundError)

    我有一个使用多个子模块的大型项目 我已将 firebase 数据库依赖项添加到我的项目中包含的模块之一 当本地测试模块作为开放项目包含时 一切正常 当使用封闭模块构建时 我的模块是aar文件 我收到以下错误 java lang NoClas
  • 如何重命名 WordPress 管理仪表板上的 WooCommerce 选项卡下的菜单选项卡

    我需要帮助重命名 WordPress 管理上 woocommerce 选项卡下的选项卡菜单项 我们安装了一个插件 该插件显示为 woocommerce 选项卡上的子菜单 有人可以帮我解决这个问题吗 我发现下面的代码可以重命名选项卡菜单 但我
  • 属性不应返回数组

    是的 我知道这个问题之前已经讨论过很多次了 我阅读了有关这个问题的所有帖子和评论 但似乎仍然无法理解一些东西 MSDN 提供的解决此违规问题的选项之一是返回收藏 or an 界面这是由一个实现的收藏 在访问该属性时 无论它多么明显并不能解决
  • Flex 默认规则

    如何自定义 Flex 的默认操作 我发现类似 的内容 但当我运行它时 它显示 柔性扫描仪卡住 还有 规则仅添加一条规则 因此它也不起作用 我想要的是 comment comment return 1 default return 0 lt
  • &'a T 是否意味着 T: 'a?

    从我自己的理解和实验来看 这似乎是正确的 但我还没有找到记录它的权威来源 Rust by Example 有一个bounds https doc rust lang org rust by example scope lifetime li
  • Google Play 中不允许使用 com.example 包名称

    我是 Android 应用程序开发新手 我正在创建简单的 Android 应用程序 导出 android 应用程序并将包名称指定为AndroidManifestfile包名为 com example zingyminds apk 现在我得到
  • 使用 FFT 进行高斯图像滤波

    对于图像分割 我使用 OpenCV 的高斯特征差异GaussianBlur 范围从 0 8 到 8 43 指数步长为 1 4 我的图像尺寸为 4096 x 2160 因此这需要相当长的时间 在一个核心上需要 8 秒 这在处理视频时相当长 您
  • 如何更改活动/选定选项卡的颜色?

    我希望当未选择选项卡时颜色为默认灰色 但作为我的颜色tabBarColor选择选项卡时的颜色 我找不到更改标签栏中标题颜色的方法 我怎样才能做到这一点 这是我的代码 Home screen TabNavigator Home screen
  • lub(T1,...Tn) 是什么意思?

    以下引用来自 JLS 14 20 http docs oracle com javase specs jls se8 html jls 14 html jls 14 20 异常参数的声明类型 将其类型表示为 与替代方案 D1 的结合D2 D
  • OpenCV 霍​​夫圆

    我使用 Xcode 和 c 我已经从以下位置复制了 HoughCircles 代码OpenCV 文档 http opencv willowgarage com documentation cpp feature detection html
  • 在 SageMath 中运行时使用 Dask 会抛出 ImportError

    最近 我一直在尝试使用 Dask 并行化一些 Sage 运行 OSX 11 2 3 的 MacBook Pro 上的 Sage 9 4 代码 我遇到的问题是 虽然我可以在 Sage 中运行 Dask 但每当我包含任何非 纯 python 代