使用cython时无效的命令'built_ext'

问题描述 投票:0回答:1

我正在尝试使用Cython在python中混淆我的代码,以便与其他用户毫无疑问地共享代码源。此外,我使用了Cython,因为它应该易于使用,这要感谢其他人的评论。

但是,当我运行一些命令时,我仍然遇到麻烦。这是我的文件:

Test.py


import numpy as np
import pandas as pd


def Test1(x, y):

    return x * y


def Test2(x, y):

    print("Export as CSV file")

    return pd.DataFrame(np.array([x, y]), columns=["A"]).to_csv('Output_file.csv', header=True, index=False, sep=',')


x = int(input("Value of x "))
y = int(input("Value of y "))

print(Test1(x, y), Test2(x, y)) 

compile.py


from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext

ext_modules = [
    Extension("Test",  ["Test.py"]),

]

setup(
    name = 'My Program Name',
    cmdclass = {'build_ext': build_ext},
    ext_modules = ext_modules
)

然后,当我启动此行:python3 compile.py built_ext --inplace时,出现以下错误消息:

   or: compile.py --help [cmd1 cmd2 ...]
   or: compile.py --help-commands
   or: compile.py cmd --help

error: invalid command 'built_ext'

有人知道如何解决吗?Thx

python ubuntu cython bytecode
1个回答
0
投票

错别字? built_extbuild_ext

© www.soinside.com 2019 - 2024. All rights reserved.