Troubleshooting Guide
This guide covers common issues you may encounter when running the inventory management system and how to resolve them.Common Issues
FileNotFoundError: No such file or directory: 'data/inventario.xlsx'
FileNotFoundError: No such file or directory: 'data/inventario.xlsx'
Problem: The system cannot find the input inventory file.Solution:
-
Verify the file exists in the correct location:
-
Create the
data/directory if it doesn’t exist: -
Ensure your Excel file is named exactly
inventario.xlsxor update the path insrc/main.py:9:
File paths are case-sensitive on Linux/macOS. Ensure the filename matches exactly.
BadZipFile: File is not a zip file
BadZipFile: File is not a zip file
Problem: The Excel file is corrupted or in an incompatible format.Solution:
-
Verify the file is a valid Excel file (
.xlsxformat, not.xls):- Open the file in Excel/LibreOffice
- Save it as
.xlsxformat (Excel Workbook)
-
Check if the file is actually an Excel file:
Should output:
Microsoft Excel 2007+ - If the file is damaged, try opening and re-saving it
KeyError: 'stock_actual' or 'ventas_mensuales'
KeyError: 'stock_actual' or 'ventas_mensuales'
Problem: Required columns are missing from the input Excel file.Solution:Your Excel file must include these exact column names:
producto— Product namestock_actual— Current stock quantitystock_minimo— Minimum stock thresholdventas_mensuales— Monthly sales volume
SMTPAuthenticationError: Username and Password not accepted
SMTPAuthenticationError: Username and Password not accepted
Problem: Email credentials are incorrect or app-specific password is required.Solution:
-
For Gmail users, enable 2-factor authentication and generate an app password:
- Go to Google Account Security
- Enable 2-Step Verification
- Generate an App Password for “Mail”
- Use the 16-character app password in your
.envfile
-
Verify your
.envfile contains valid credentials: -
For non-Gmail accounts, update the SMTP server in
src/emailer.py:30:
The system is configured for Gmail by default. Other providers may use different SMTP servers and ports.
SMTPServerDisconnected: Connection unexpectedly closed
SMTPServerDisconnected: Connection unexpectedly closed
Problem: SMTP connection is blocked by firewall or using wrong port.Solution:
- Check your firewall allows outbound connections on port 465
-
Try alternative SMTP configuration using STARTTLS (port 587):
-
Verify your network allows SMTP traffic:
ModuleNotFoundError: No module named 'pandas'
ModuleNotFoundError: No module named 'pandas'
Problem: Required Python dependencies are not installed.Solution:
-
Install all dependencies from
requirements.txt: -
Verify Python version (requires Python 3.6+):
-
If using a virtual environment, ensure it’s activated:
-
Install specific missing package:
PermissionError: Permission denied: 'output/reporte_inventario.xlsx'
PermissionError: Permission denied: 'output/reporte_inventario.xlsx'
Problem: The output file is open in Excel or lacks write permissions.Solution:
- Close the Excel file if it’s currently open
-
Check file permissions:
-
Grant write permissions if needed:
-
Remove the file and regenerate it:
ValueError: All arrays must be of the same length
ValueError: All arrays must be of the same length
Problem: Data inconsistency in the Excel file (missing values or irregular rows).Solution:
- Check for empty rows in your Excel file and remove them
- Ensure all required columns have values for every product
-
Add validation to handle missing data in
src/loader.py:
Email sent but attachment is missing
Email sent but attachment is missing
Problem: The report file doesn’t exist when the email is sent.Solution:
-
Verify the file was generated before sending:
-
Add validation in
src/main.pybefore callingenviar_reporte: - Check for errors during report generation in the console output
Debugging Tips
Environment Variables
If email functionality is not working, verify your.env file:
Getting Help
If you encounter an issue not covered here:- Check the logs — Review console output for error messages
- Verify file paths — Ensure all input/output paths are correct
- Test dependencies — Confirm all packages are installed correctly
- Review the code — Check
src/files for hardcoded paths or configurations
Module Reference
Review detailed documentation for all system modules and functions