Python Logger file throwing error while compiling for toadex verdin IMX8mm board

Hi,
I have created a logger file to log the system information. while I compile my python application it works fine and deploys the build on the server. When I tried to run the code in verdin IMX8mm board it throws exception and does not deploy or run the build on the device.
Here is the few lines of the code for logging.
import logging

Basic configuration

logging.basicConfig(level=logging.DEBUG,format=‘%(asctime)s - %(name)s - %(levelname)s - %(message)s’,filename=‘app.log’,filemode=‘w’)

Create a logger

logger = logging.getLogger(name)
It throws exception on the first line.

Thanks
Pramod

Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hi Pramod,

Based on the information provided, it seems like your Python logger configuration is causing an issue when running on the Verdin iMX8MM board. Here are a few steps to troubleshoot and resolve the issue:

  1. Check Python Version: Ensure that the Python version on your Verdin iMX8MM board is compatible with the version you used during development. You can check the Python version by running:

    python --version
    
  2. File System Permissions: Verify that the directory where you are trying to create the log file (app.log) has the necessary write permissions. You can check and modify permissions using:

    ls -l /path/to/directory
    chmod +w /path/to/directory
    
  3. Encoding Issues: Ensure that the file encoding is consistent. Sometimes, encoding issues can cause problems when running scripts on different systems.

  4. Syntax Error in Logging Configuration: There seems to be a syntax issue in your logging configuration. The quotes used in the format parameter are not standard single quotes. Replace them with standard single quotes ('). Also, the **name** should be __name__. Here is the corrected code:

    import logging
    
    # Basic configuration
    logging.basicConfig(level=logging.DEBUG,
                        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
                        filename='app.log',
                        filemode='w')
    
    # Create a logger
    logger = logging.getLogger(__name__)
    
  5. Dependencies: Ensure that all necessary Python packages are installed on the Verdin iMX8MM board. You can install required packages using pip:

    pip install -r requirements.txt
    
  6. Run the Script Manually: Try running the script manually on the Verdin iMX8MM board to see if it provides more detailed error messages:

    python your_script.py
    

If the issue persists after these steps, please provide the exact error message you are encountering, and any additional context that might help in diagnosing the problem.

Best regards,
[Your Name]

Please, also check if these links can help you solve your problem:

Debugging QT project on Col VF61.

Greetings @samalpamod,

Maybe you can share the exception/log you are getting? It’s quite difficult for us to offer any comments without seeing the actual error first.

Best Regards,
Jeremias