gpt4 book ai didi

python - cython pyximport 在哪里编译?

转载 作者:太空狗 更新时间:2023-10-29 22:09:14 27 4
gpt4 key购买 nike

我的 cython/pyximport 代码在读/写文件系统上运行良好。

但是(出于测试目的),我需要在只读文件系统 上进行尝试。

如何更改cython/pyximport临时目录? (它在哪里完成工作?即即时编译?)

如何将此“工作目录”设置为当前目录以外的其他位置,例如 /tmp/(不是 ro,而是 rw) ?


回溯:

!!   File "/usr/lib/python2.7/site-packages/Cython/Distutils/build_ext.py", line 301, in cython_sources
self.mkpath(os.path.dirname(target))
!! File "/usr/lib/python2.7/distutils/cmd.py", line 352, in mkpath
dir_util.mkpath(name, mode, dry_run=self.dry_run)
!! File "/usr/lib/python2.7/distutils/dir_util.py", line 76, in mkpath
"could not create '%s': %s" % (head, exc.args[-1]))
!! ImportError: Building module samplerbox_audio failed: ["DistutilsFileError: could not create '/root/.pyxbld': Read-only file system\n"]

最佳答案

来自 help(pyximport.install)

By default, compiled modules will end up in a .pyxbld directory in the user's home directory. Passing a different path as build_dir will override this.

因此,当您调用 pyximport.install 以使其使用您的读/写系统时,将 build_dir 作为参数传递。

关于python - cython pyximport 在哪里编译?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30079858/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com