Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

cython - How do I import function from .pyx file in python?

I'm trying to run Hadoopy, which has a file _main.pyx, and import _main is failing with module not found in __init__.py.

I'm trying to run this on OS X w/ standard python 2.7.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Add this code before you try to import _main:

import pyximport
pyximport.install()

Note that pyximport is part of Cython, so you'll have to install that if it isn't already.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...