cython - What method can I use instead of __file__ in python? -
i convert python code c cython , after compile .c file , use .so in project. problem: use __file__
in python code , in while compile gcc, doesn't error. when run program , import .so in other python files, appear error __file__
line.
how can solve problem? there method replace __file__
?
try add @ beginning of file:
import inspect if not hasattr(sys.modules[__name__], '__file__'): __file__ = inspect.getfile(inspect.currentframe())
Comments
Post a Comment