首页 > 解决方案 > Google colab 中的 cython 模块中的编译错误

问题描述

我正在尝试在 google colab 中编译一个小的 Cython 文件 (*.pyx)。 cythonize成功没有问题,产生一个 *.c 文件。后来,打电话时:

from distutils.core import setup
from Cython.Build import cythonize

cythonized = cythonize("module_path.pyx")
setup(name="my_module", ext_modules=cythonized)

我得到:

DistutilsArgError                         Traceback (most recent call last)
/usr/lib/python3.7/distutils/core.py in setup(**attrs)
    133     try:
--> 134         ok = dist.parse_command_line()
    135     except DistutilsArgError as msg:

/usr/lib/python3.7/distutils/dist.py in parse_command_line(self)
    475         parser.set_aliases({'licence': 'license'})
--> 476         args = parser.getopt(args=self.script_args, object=self)
    477         option_order = parser.get_option_order()

/usr/lib/python3.7/distutils/fancy_getopt.py in getopt(self, args, object)
    234         except getopt.error as msg:
--> 235             raise DistutilsArgError(msg)
    236 

DistutilsArgError: option -f not recognized

An exception has occurred, use %tb to see the full traceback.

SystemExit: usage: ipykernel_launcher.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: ipykernel_launcher.py --help [cmd1 cmd2 ...]
   or: ipykernel_launcher.py --help-commands
   or: ipykernel_launcher.py cmd --help

error: option -f not recognized

我发现有问题的论点是:

['-f', '/root/.local/share/jupyter/runtime/kernel-SOME_HASH-4fdbaebc4675.json']

这个命令在哪里定义?如何解决?

标签: pythongoogle-colaboratorycythondistutils

解决方案


推荐阅读