python - “”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 及其内容。
希望这里有人可以帮助我。
额外信息
- 我正在使用 Arch Linux
- 我有最新的 Python 版本
- 我使用 Neovim 作为我的编辑器,你可以在这里找到它的点文件。
解决方案
你是如何尝试运行它的?我刚刚克隆了你的回购并运行:
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 这样的类型检查器看到这个错误?
推荐阅读
- spring-boot - 如何在 ActiveMQ 上配置 JmsListener 以使用 Qpid Sender 进行自动缩放
- c - 如何添加矩阵的对角线和半对角线
- snakemake - 一个规则的输出作为另一个规则的输入
- multithreading - Swift:如何中断排序例程
- nix - 根据属性向 stdenv 添加一个 shell 函数
- ftp - 无法在genexus上使用ftp保存文件
- r - 从带有逗号分隔列表的单元格进行 Vlookup 或表连接
- css - Flex div 无法正确渲染
- c# - C# 在 Microsoft.Office.Interop.Word.List 的列表项中获取第二段
- terraform - 将新权限附加到 AWS 中的角色