[英]Upload code to AWS lambda error Runtime.ImportModuleError
I am trying to put this scraping code on AWS Lambda, when i try to test the code i get the following error:我正在尝试将此抓取代码放在 AWS Lambda 上,当我尝试测试代码时出现以下错误:
"errorMessage": "Unable to import module 'lambda_function': No module named 'lambda_function'",
"errorType": "Runtime.ImportModuleError"
The code:编码:
from datetime import datetime
from functions import MultiplePageScraper, CleanTable, upload_unique, pages
from sqlalchemy import create_engine
now = datetime.now()
date = now.date()
# Credentials:
host = xxxxx
user = "admin"
password = xxxxx
port = 3306
database = "vehicles"
# Create connection
mydb = create_engine("mysql+pymysql://" + user + ':' + password + '@' + host + ':' + str(port) + '/' + database , echo=False)
# Target Url :
URL = "https://www.usedcars.co.ke/nairobi/cars-for-sale?page="
def lambda_handler(event, context):
# Retrive the data and clean it
page_count = pages(URL)
data = MultiplePageScraper(URL, int(page_count))
clean_data = CleanTable(data)
# Check for duplicates scraped Vs Database
upload_data = upload_unique(clean_data, mydb)
# Upload data to RDS database
if upload_data.shape[0] > 1:
upload_data.to_sql(name='CARS', con=mydb, if_exists = 'append', index=False)
print(f'Uploaded {upload_data.shape[0]} unique rows to the database!')
else:
print('No new cars to upload.')
I have no idea what the error means, any one can help?我不知道错误是什么意思,任何人都可以帮忙吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.