Cython ImportError:没有名为并行的模块
我正在尝试访问 Cython 0.15 的新并行功能(使用 赛通 0.15.1)。但是,如果我尝试这个最小的示例(testp.py),取自 http://docs .cython.org/src/userguide/parallelism.html:
from cython.parallel import prange, parallel, threadid
cdef int i
cdef int sum = 0
for i in prange(n, nogil=True):
sum += i
print sum
使用此 setup.py:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
import numpy
ext = Extension("testp", ["testp.pyx"], include_dirs=[numpy.get_include()],
extra_compile_args=['-fopenmp'], extra_link_args ['-fopenmp'])
setup(ext_modules=[ext], cmdclass={'build_ext': build_ext})
当我导入 testp
时,Python 告诉我:ImportError:没有名为的模块 并行。事实上,如果我浏览 Cython 包 site-packages,我找不到任何名为的文件或目录
并行
。但我认为它应该包含在 发布?有人可以为困惑的用户澄清一下吗?
I am trying to access the new parallel features of Cython 0.15 (using
Cython 0.15.1). However, if I try this minimal example (testp.py), taken from http://docs.cython.org/src/userguide/parallelism.html:
from cython.parallel import prange, parallel, threadid
cdef int i
cdef int sum = 0
for i in prange(n, nogil=True):
sum += i
print sum
with this setup.py:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
import numpy
ext = Extension("testp", ["testp.pyx"], include_dirs=[numpy.get_include()],
extra_compile_args=['-fopenmp'], extra_link_args ['-fopenmp'])
setup(ext_modules=[ext], cmdclass={'build_ext': build_ext})
when I import testp
, Python tells me: ImportError: No module named
. And in fact, if I browse the Cython package in the
parallel
site-packages, I cannot find any file or directory that is calledparallel
. But I thought it should be included somewhere in the
release? Could someone please clarify for a confused user?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我正在使用 Cython 0.15+
cython.parallel 存在于 Shadow.py 中:
并且
Shadow.py
可以位于 Python 的 dist-packages 目录中,例如/usr/local/lib/python2 Linux 中的 .6/dist-packages/
I'm using Cython 0.15+
cython.parallel exists in Shadow.py:
And the
Shadow.py
can be located in your Python's dist-packages directory like/usr/local/lib/python2.6/dist-packages/
in Linux您可以使用以下命令在 python 命令行中检查所有 python 模块:
然后尝试使用 easy_install 或 pip 安装/重新安装 cython。
You can check all of your python modules in python command-line using:
And then try to install/reinstall cython using easy_install or pip.