• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

MMM-PythonPrint customisation

Scheduled Pinned Locked Moved Solved Troubleshooting
46 Posts 5 Posters 12.5k Views 5 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    RobCee
    last edited by Apr 1, 2022, 4:03 PM

    @SDETWEIL, firstly, thank you for creating such a simple to follow module for talking to python. I have been trying to get that working for a while and was struggling.

    My issue is that I require a specific library (zeep) for my python code to work, but if I include it in the code with the line include zeep , the module throws an error.

    [01.04.2022 16:45.32.503] [LOG]   MMM-PythonPrint received a socket notification: CONFIG - Payload: [object Object]
    [01.04.2022 16:45.32.507] [LOG]   PythonPrint spawning /opt/magic_mirror/modules/MMM-PythonPrint/test.py
    [01.04.2022 16:45.32.606] [ERROR] Whoops! There was an uncaught exception...
    [01.04.2022 16:45.32.614] [ERROR] ReferenceError: data is not defined
        at ChildProcess.<anonymous> (/opt/magic_mirror/modules/MMM-PythonPrint/node_helper.js:20:65)
        at ChildProcess.emit (node:events:394:28)
        at Process.ChildProcess._handle.onexit (node:internal/child_process:288:12)
        at onErrorNT (node:internal/child_process:477:16)
        at processTicksAndRejections (node:internal/process/task_queues:83:21)
    

    Now, my python code runs successfully from the command line and I have commented everything else out while troubleshooting. I also see the same behaviour if I add the include zeep line into your sample .py files, which run correctly without this.

    Any ideas what is going on? Could it be a path/user/install issue with the python module?

    Cheers, RobCee

    S 1 Reply Last reply Apr 1, 2022, 4:25 PM Reply Quote 0
    • D Offline
      diemen112
      last edited by diemen112 Jul 15, 2022, 8:18 PM Jul 15, 2022, 7:51 PM

      Thank you for the help,
      I made it work with adding some python dependent directory’s to the docker-compose file

      1 Reply Last reply Reply Quote 1
      • S Offline
        sdetweil @RobCee
        last edited by Apr 1, 2022, 4:25 PM

        @RobCee its because python has its own library path…

        see here, https://stackoverflow.com/questions/55565924/error-importing-installed-python-packages-in-nodejs-pyshell

        last post, for the approach to solve in your python script.
        (if you don’t login, then u have to cursor over some strikethrus… (dumb)…)

        I don’t know python that well, so I don’t know if there is a way to catch the include failure and then add the path and then redo the include) … altho it shouldn’t hurt to always add the path as it would be there from the commandline

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        R 1 Reply Last reply Apr 1, 2022, 4:28 PM Reply Quote 0
        • R Offline
          RobCee @sdetweil
          last edited by Apr 1, 2022, 4:28 PM

          @sdetweil I thought it would be something daft like this. Thanks for the pointer, I will take a look and see if I can resolve it.
          Super speedy response too.

          S 1 Reply Last reply Apr 10, 2022, 8:42 PM Reply Quote 0
          • S sdetweil referenced this topic on Apr 1, 2022, 7:34 PM
          • S sdetweil referenced this topic on Apr 1, 2022, 7:41 PM
          • S Offline
            sdetweil @RobCee
            last edited by Apr 10, 2022, 8:42 PM

            @RobCee were you able to resolve the exec of the python script?

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            R 1 Reply Last reply Apr 11, 2022, 3:36 PM Reply Quote 0
            • R Offline
              RobCee @sdetweil
              last edited by RobCee Apr 11, 2022, 3:37 PM Apr 11, 2022, 3:36 PM

              @sdetweil I haven’t managed to get it running yet.
              I did have some success (I had it printing Hello on the screen), but then the wheels came off and I have been unable to get it working again.

              I have reverted to the default configuration from your Github page to try and wiork out what is going on, but I am seeing the following in the logs:

              [11.04.2022 16:30.34.903] [LOG]   Connecting socket for: MMM-PythonPrint
              [11.04.2022 16:30.34.907] [LOG]   Starting module helper: MMM-PythonPrint
              [11.04.2022 16:30.43.341] [LOG]   MMM-PythonPrint received a socket notification: CONFIG - Payload: [object Object]
              [11.04.2022 16:30.43.346] [LOG]   PythonPrint spawning /opt/magic_mirror/modules/MMM-PythonPrint/printitonce.py
              [11.04.2022 16:30.43.531] [ERROR] Whoops! There was an uncaught exception...
              [11.04.2022 16:30.43.556] [ERROR] ReferenceError: data is not defined
                  at ChildProcess.<anonymous> (/opt/magic_mirror/modules/MMM-PythonPrint/node_helper.js:20:65)
                  at ChildProcess.emit (node:events:390:28)
                  at Process.ChildProcess._handle.onexit (node:internal/child_process:288:12)
                  at onErrorNT (node:internal/child_process:477:16)
                  at processTicksAndRejections (node:internal/process/task_queues:83:21)
              

              Which seems to be the same error as before, but now I am not using any 3rd party modules, just the sample code.

              S 1 Reply Last reply Apr 11, 2022, 3:40 PM Reply Quote 0
              • S Offline
                sdetweil @RobCee
                last edited by Apr 11, 2022, 3:40 PM

                @RobCee said in MMM-PythonPrint customisation:

                ReferenceError: data is not defined

                are u launching ‘python’ or python3?

                the default
                const python=‘python’

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                R 1 Reply Last reply Apr 11, 2022, 3:41 PM Reply Quote 0
                • R Offline
                  RobCee @sdetweil
                  last edited by Apr 11, 2022, 3:41 PM

                  @sdetweil I am using python3 and I have updated the two references to ‘python’ -> ‘python3’ to reflect this

                  S 1 Reply Last reply Apr 11, 2022, 3:43 PM Reply Quote 0
                  • S Offline
                    sdetweil @RobCee
                    last edited by Apr 11, 2022, 3:43 PM

                    @RobCee right, you don’t have to change the code, just use the config.js setting

                    { 
                    module:
                         config: {  
                             pythonName:'python3',
                        }
                    }
                    

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

                    R 1 Reply Last reply Apr 11, 2022, 3:44 PM Reply Quote 0
                    • R Offline
                      RobCee @sdetweil
                      last edited by Apr 11, 2022, 3:44 PM

                      @sdetweil ok, I will try it there then and see what happens.
                      Tracking down errors in this MM OS is fun…

                      S 1 Reply Last reply Apr 11, 2022, 3:57 PM Reply Quote 0
                      • S Offline
                        sdetweil @RobCee
                        last edited by sdetweil Apr 11, 2022, 3:59 PM Apr 11, 2022, 3:57 PM

                        @RobCee o, I see that I have a potential bug… if the command: is not configured,
                        it defaults to “”… oops…

                        I just pushed an update got that

                        git pull in the module folder

                        to debug

                        add debug: true

                        and then look where u start MM… (this doing npm start )

                        [11.04.2022 10:55.13.087] [LOG]   MMM-PythonPrint received a socket notification: CONFIG - Payload: [object Object]
                        [11.04.2022 10:55.13.087] [LOG]   PythonPrint spawning modules/MMM-PythonPrint/printit.py
                        .
                        .
                        .
                        .
                        [11.04.2022 10:55.18.114] [LOG]   PythonPrint sending program output=hello
                        

                        Sam

                        How to add modules

                        learning how to use browser developers window for css changes

                        R 1 Reply Last reply Apr 11, 2022, 3:59 PM Reply Quote 0
                        • 1
                        • 2
                        • 3
                        • 4
                        • 5
                        • 1 / 5
                        • First post
                          Last post
                        Enjoying MagicMirror? Please consider a donation!
                        MagicMirror created by Michael Teeuw.
                        Forum managed by Sam, technical setup by Karsten.
                        This forum is using NodeBB as its core | Contributors
                        Contact | Privacy Policy