我首先使用AWS sam cli 在本地开发python应用程序。
我已经使用sam build
命令来安装Requirements.txt中提到的python软件包。使用依赖包文件夹创建Build文件夹,
但是在代码中,import
语句显示could not import the package.
,尽管它与我的代码位于同一文件夹中。
答案 0 :(得分:1)
显示错误消息是因为未class LoginPrompt:
def Login(self):
while True:
print(menu[1])
self.Card_number=str(input('>> '))
print(menu[2])
self.Character_PINs = getpass.getpass('>> ')
self.one_row = c.execute('SELECT * FROM {tn} WHERE {cn}=? and {cnn}=?'.\
format(tn=table_1, cn=column_1, cnn=column_3), (self.Character_PINs, self.Card_number,))
for row in self.one_row.fetchone():
print('Welcome: ', row)
return
else:
print('PIN incorrect; try again')
def loginMenu(self):
while True:
print(menu[5])
print("\n1 - Deposit funds")
print("2 - Withdraw funds")
print("3 - Check balance")
print("4 - Reset Pin")
print("5 - Exit")
while True:
try:
choice = int(input("Please enter a number: "))
except ValueError:
print("This is not a number")
if choice >= 1 and choice <=5:
if choice == 1:
amount = input("\nPlease enter the deposit amount: ")
if amount != '' and amount.isdigit():
int(amount)
amount = c.execute('UPDATE {tn} SET Balances = ? WHERE {cn}=?'.\
format(tn=table_1, cn=column_2), (amount,))
else:
print("Please enter a valid number")
conn.commit()
conn.close
elif choice ==3:
print(Login.one_row)
elif choice ==5:
input('Enjoy your stay, and always remember to drink Nuka Cola! ')
return(mainMenu)
else:
return
def mainMenu():
print(menu[0])
chosen=False
while not chosen:
opt=int(input('\n Please choose one of the options below:\n\n-> Register for a new account [1]\n-> Login to an existing account [2]\n\nPlease type a number...\n\n>> '))
if opt==1:
userReg()
chosen=True
elif opt==2:
login_Menu = LoginPrompt()
login_Menu.Login()
chosen=True
login_Menu.loginMenu()
else:
print('\n\nPLEASE TYPE EITHER 1 OR 2...\n ')
print(chosen)
if __name__ == "__main__":
while True:
mainMenu()
将软件包安装为项目路径内的软件包,因此未打包为python软件包安装,因此可以将其打包为层并部署到AWS Lambda层中