运行控制台脚本时,获取““ ImportError:模块'test'没有属性'main'”

时间:2018-08-24 13:35:52

标签: python setup.py entry-point

这是我的测试。py

array(
    '$or' => array(
        array("first_name" => new MongoDB\BSON\Regex("/poo/i")),
        array("middle_name" => new MongoDB\BSON\Regex("/poo/i")),
        array("last_name" => new MongoDB\BSON\Regex("/poo/i"))
    ),
    "$expr" => array(
        "$eq" => array(
            array("$arrayElemAt" => array("$transport_details.status", -1)),
            "Active"
        )
    )
);

这是我的setup.py

import sys,os,glob
from colorama import Fore, Back, Style, init

init(autoreset = True)

def main():
    print(Fore.GREEN + "Hello World")


if __name__ == '__main__':
    main()

在我给的命令提示符下

from setuptools import setup, find_packages

setup(
    name = "PROJ_1",
    version = "0.2",
    py_modules = ['PROJ_1\\test'],
    packages = find_packages(),
    install_requires = ['click'],
    entry_points = {
       'console_scripts' : ['tst =test:main',]
    }
)

构建成功,以下是最终日志:

python setup.py develop

当我运行控制台脚本'tst'时,出现以下错误:

ImportError:模块“ test”没有属性“ main”

Installed c:\python_try\python_proj\proj_1
Processing dependencies for PROJ-1==0.2
Searching for click==6.7
Best match: click 6.7
Adding click 6.7 to easy-install.pth file

Using c:\anaconda3\lib\site-packages
Finished processing dependencies for PROJ-1==0.2

我对Python还是比较陌生,任何帮助将不胜感激。

0 个答案:

没有答案