首页 > 解决方案 > “”fullSetup“不是模块的已知成员”错误似乎没有导致它

问题描述

我正在尝试使用 Python 和 Bash 编写安装后脚本,但在定义函数时遇到了麻烦。下面是程序的主文件:

#!/usr/bin/env python3

import variables


# Main program loop
while True:
    userResponse = str.lower(input('''What would you like to do?
    f: Starts the full post-install setup
    u: Starts configuring users
    p: Starts the packages setup
    s: Starts the systemctl setup
    c: Starts the configs setup
    q: Terminates the program\n'''))


    if userResponse == 'f':
        print('Starting full post-install setup...')
        variables.fullSetup()

    elif userResponse == 'u':
        variables.configureUsers()

    elif userResponse == 'p':
        variables.installEssentialPackages()

    elif userResponse == 's':
        variables.configureSystemctl()

    elif userResponse == 'c':
        variables.configureSystem()

    elif userResponse == 'q':
        print('Terminating program...')
        quit()

    else:
        print('Input not recognized.')

这是variables文件:

import subprocess


def configureUsers():
    print('Attempting to configure system users...')
    subprocess.run(
            './post_install_scripts/01_users.sh',
            shell = True)

def installEssentialPackages():
    print('Attempting to install essential packages...')
    subprocess.run(
            './post_install_scripts/02_pkgs.sh',
            shell = True)

def configureSystemctl():
    print('Attempting to configure systemctl...')
    subprocess.run(
            './post_install_scripts/03_systemctl.sh',
            shell = True)

def configureSystem():
    print('Attempting to configure system...')
    subprocess.run(
            './post_install_scripts/04_configs.sh',
            shell = True)

def fullSetup():
    print('Attempting to run a full setup...')
    configureUsers()
    installEssentialPackages()
    configureSystemctl()
    configureSystem()

在 上line #19,我收到以下错误:

"fullSetup" is not a known member of a module

我不明白我在这里做错了什么。在我看来一切都很好。如果您想在 Github 上查看整个 repo,可以点击此链接查看整个 repo 及其内容。

希望这里有人可以帮助我。

额外信息

标签: pythonlinuxbasharchlinux

解决方案


你是如何尝试运行它的?我刚刚克隆了你的回购并运行:

python3 setup.py

我明白了:

What would you like to do?
    f: Starts the full post-install setup
    u: Starts configuring users
    p: Starts the packages setup
    s: Starts the systemctl setup
    c: Starts the configs setup
    q: Terminates the program

这是使用 Python 3.7。

我应该进一步澄清一下,您是在运行代码时看到这个错误,还是只是从像 mypy 这样的类型检查器看到这个错误?


推荐阅读