Menu

ModuleNotFoundError: No module named '_support'

Anonymous
2018-02-09
2022-04-24
  • Anonymous

    Anonymous - 2018-02-09

    Welcome!
    I generated simple window with button and entry wiget. I copy code to my PYcharm and run the code . In line 20 I had error. ModuleNotFoundError: No module named '_support'
    I did it in Jupyter and it show the same error. I have python 3.6
    Program seems to be great and I apriciate it but how to change code to work in my python editor?
    Code:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    #! /usr/bin/env python
    #
    # GUI module generated by PAGE version 4.10
    # In conjunction with Tcl version 8.6
    #    Feb 09, 2018 05:24:03 PM
    import sys
    
    try:
        from Tkinter import *
    except ImportError:
        from tkinter import *
    
    try:
        import ttk
        py3 = 0
    except ImportError:
        import tkinter.ttk as ttk
        py3 = 1
    
    import _support
    
    def vp_start_gui():
        '''Starting point when module is the main routine.'''
        global val, w, root
        root = Tk()
        top = New_Toplevel_1 (root)
        _support.init(root, top)
        root.mainloop()
    
    w = None
    def create_New_Toplevel_1(root, *args, **kwargs):
        '''Starting point when module is imported by another program.'''
        global w, w_win, rt
        rt = root
        w = Toplevel (root)
        top = New_Toplevel_1 (w)
        _support.init(w, top, *args, **kwargs)
        return (w, top)
    
    def destroy_New_Toplevel_1():
        global w
        w.destroy()
        w = None
    
    class New_Toplevel_1:
        def __init__(self, top=None):
            '''This class configures and populates the toplevel window.
               top is the toplevel containing window.'''
            _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
            _fgcolor = '#000000'  # X11 color: 'black'
            _compcolor = '#d9d9d9' # X11 color: 'gray85'
            _ana1color = '#d9d9d9' # X11 color: 'gray85'
            _ana2color = '#d9d9d9' # X11 color: 'gray85'
    
            top.geometry("600x450+433+140")
            top.title("New Toplevel 1")
            top.configure(background="#d9d9d9")
    
            self.Button1 = Button(top)
            self.Button1.place(relx=0.08, rely=0.09, height=24, width=47)
            self.Button1.configure(activebackground="#d9d9d9")
            self.Button1.configure(activeforeground="#000000")
            self.Button1.configure(background="#d9d9d9")
            self.Button1.configure(disabledforeground="#a3a3a3")
            self.Button1.configure(foreground="#000000")
            self.Button1.configure(highlightbackground="#d9d9d9")
            self.Button1.configure(highlightcolor="black")
            self.Button1.configure(pady="0")
            self.Button1.configure(text='''Button''')
    
            self.Entry1 = Entry(top)
            self.Entry1.place(relx=0.23, rely=0.09,height=20, relwidth=0.27)
            self.Entry1.configure(background="white")
            self.Entry1.configure(disabledforeground="#a3a3a3")
            self.Entry1.configure(font="TkFixedFont")
            self.Entry1.configure(foreground="#000000")
            self.Entry1.configure(insertbackground="black")
    
    if __name__ == '__main__':
        vp_start_gui()
    
     
  • Don Rozenberg

    Don Rozenberg - 2018-02-10

    I need more information. When PAGE generates a GUI module it saves the project file with a project name that you select and an extension of "tcl". Did you see a "Save Project Dialog? Did you supply a name or accept the defult name "unknown.tcl"? It looks as though you did a cancel . You also have to generate the corresponding support module in PAGE. Could you send me the project file and I will look at it.

     
  • Anonymous

    Anonymous - 2018-02-10

    I have got it now. I need to Generate Python GUI and generate Support module to everything working. I did only copy the code and paste to my Pycharm editor. Now I save generated project and open in Pycharm and it working. I didn' t realise that it will need the support module to working properly. Thank You. I will continue to discover Python.

     
    • Anonymous

      Anonymous - 2022-03-11

      Hi All,
      Rather than create a new topic, this seems to be the closest to my problem. I created a window with multiple text entry widgets, a few buttons and some color changing labels. Following the PAGE convention I generated a "serial6.py" file and a "serial6_support.py" file. Because this project must communicate over a serial port I installed PySerial and then my support file imports "serial". This all works perfectly and I have been able to prove my testing concept. Now I would like to make the project stand alone so I can test it on various OSs and Platforms.

      I have used auto-py-to-exe to package the project but I have two problems:

      1. ModuleNotFoundError: No module named 'serial' when I try to run the .exe
      2. It is not clear which of the two files I should choose for PyInstaller (serial6 or serial6_support)... I've tried both

      I have tried both files with the "One directory" selected and I have tried both Console based and Window based with no change in the error.

      I have been developing in Thonny which has perfomed with no problems. I assume that since I can seamlessly interface with my serial port under Thonny, that PySerial has been installed properly. I can only guess that the "serial"module is just not in the directory with serial6.py and serial6_support.py. However I can't find anything that resembles the serial module so I can point pyinstaller to it to include (or copy it to my project folder).

      There must be something I'm missing and the auto py to exe troubleshooting docs don't have an obvious solution.

      I've attached the project files but these files are now a hybrid of both the PAGE generated files and the modifications I've made manually in order to get the serial communication and a few other cosmetic changes to the interface window to work.

      Thanks for any help

       
  • Greg Walters

    Greg Walters - 2022-03-12

    Unfortunately, I have no experience with auto-py-to-exe or any of the other python to exe programs.

    That having been said, it sounds like the py-to-exe program can't find the PySerial library. From what I understand, this can usually be added as a required file in one of the scripts that the compressor program uses to build the project into the exe.

    I've never been able to successfully create an exe file from any PAGE project. I'm certain it's possible, since one of the Discord forum users said that he uses that kind of program to distribute his PAGE projects often.

    All we can offer is our hope that you can get this figured out.

    Greg

     
  • Anonymous

    Anonymous - 2022-03-14

    Hi Greg,
    Here's what I discovered. I use Thonny for my generic Python IDE.

    -Installing PySerial puts a folder called "serial" into "Program Files (x86 ) where Thonny is installed. : (i.e. C:\Program Files (x86)\Thonny\Lib\site-packages\serial)
    -Thonny has no problem finding this folder when I invoke "include serial" in my project.
    -PyInstaller chokes, however, if it can't find the "serial" module in the project directory.
    -I copied this "serial" folder into the project directory where my ---.py and ---support.py. project
    files are located.
    -The Auto Py to Exe GUI asks for the directory where the target script resides. Since PAGE generates two project files it wasn't obvious which script I should use as my target for Auto Py to Exe so I tried both.
    -Using the ...support.py file created several errors when I tried to run the .exe, However, the ....py file worked almost exactly as advertised.
    It opened the expected window, executed all the functions that are associated with my buttons, found an unused serial com port, communicated correctly over the serial port to my microprocessor and correctly passed a number of strings from my text entry widgets seamlessly.

    To Recap, make sure that any modules that might be not native to Python that are going be included are in the same directory as the target script file. It seems that PySerial is not built into Python. As for PAGE projects, select the -----.py file as the Auto Py to Exe target and not the ----support.py file. I have only tested the "One Directory" configuration which purports to create a folder with all the necessary components. The exe file is in this directory.

    There are two issues that I need to address.....
    1. The test exe resides on a PC that has Thonny and Python installed and it may not be a really clean test of the stand-alone exe version. I'll have to make the proof of concept hardware more portable to move it to other PCs that have no trace of Thonny or Python to be sure but this is encouraging.
    2. In the Thonny IDE, my buttons have labels associated with them that change color when successfully invoked. When the final button is pushed to send the accumulated data down the serial port all of the labels revert to red and the process is reset waiting for another cycle if desired. The executable just created doesn't change the label colors when the final process is run but the functions seem to be successfully executing......

    The Auto Py to Exe utility offers the option to run with a Console. I'm going to guess that this will allow some diagnostic information. I'm going to try this shortly, to see what is keeping the labels from resetting back to red....

    I hope this helps anyone trying to get a PAGE project to stand alone

    Cheers.

     
  • Greg Walters

    Greg Walters - 2022-03-14

    I'm glad that you were able to make head way.

    I'm sure you will get it all worked out.

    Greg

     
  • Anonymous

    Anonymous - 2022-03-14

    Further observation.... when I changed auto py to exe output to include console, everything worked just like in the Thonny IDE. Buttons reset to red, etc..... not sure why but I have to start testing the hardware so it will be awhile before I can dig into this anomaly.... Later..

     
  • Mike Roberts

    Mike Roberts - 2022-03-17

    Further observations from my anonymous posts above. (I just discovered how I can login.... my browser <seamonkey> is not displaying the Login link correctly...) .</seamonkey>

    This Post addresses [ModuleNotFoundError: No module named '_support' ], [Converting a PAGE project generated script to exe] and [Odd loss of focus after using tkinter messagebox on Windows 10 platforms].

    At the moment I can only run Auto Py to Exe from a Windows 7 machine but I've tested the exe on multiple W7 and W10 machines successfully.
    
    1. Make sure that both <project>.py and <project_support>.py are inside the directory that is the "Script Location"  in the  Auto Py to Exe GUI.  {Of course, if you have any additional modules or objects that must be included make sure they are in the same directory as well.  i.e. If you need serial routines find the PySerial folder/module } named "serial" and copy it into the directory with <project>.py and <project_support>.py
    2. It appears that you can choose either the <project>.py or <project_support>.py file as the script to open as the "Script Location".  Both seem to generate a workable exe that behaves correctly.  
    3. I've tested both One Directory and Onefile output and both work with a  PAGE project output. (Neither output requires "installation" just put it onto the target PC and running the executable works as expected.  NOTE that One Directory will create a folder filled with a large number of support files.  I found that the exe file should be run from within that directory.   Onefile will generate a single exe file that is roughly as large as the previous directory but will run from anywhere on the target PC without "installation" and no difference in performance.
    4. If you choose to run the exe as" Console Based" the exe will open a CMD window and will execute showing any console directed outputs in the CMD window (e.g. print('Function xyz just executed').  NOTE that this will slightly slow down the execution of your code.  Some features of the Python code will not run correctly if not slowed down.  Particularly some of the serial utilities tend to hang when attempting to communicate with a microprocessor.  I have not exhaustively tested this but adding a short delay on some non-time critical functions has fixed some crashes I've experienced.  (I noticed that these crashes did not happen when in "console" mode)
    5. Finally I used tkinter "messagebox" to help with some branching and discovered that after selecting "yes" or "No" I could not get any of the text entry widgets to accept focus to input strings.   In another topic some people have experienced this after using messagebox.  I was able to redirect focus back using "root.focus_force()" after exiting from messagebox.
    
     
  • Mike Roberts

    Mike Roberts - 2022-03-17

    Sorry about the crazy formatting above..... these text entry boxes appear to have abandoned <cr> and <lf> part way through my post and have started treating quotes as comment delimiters... </lf></cr>

     
  • Greg Walters

    Greg Walters - 2022-03-18

    Thank you, Mike for sharing this valuable information.

    Greg

     
  • Jean Pierre Chaminade

    Hi Mike, Greg and others,
    I usually generate exe for WIN10 with pyinstaller and it works well :
    python -m PyInstaller --onedir --windowed -i MyApp.ico MyApp.py
    where MyApp.py is the file name of the GUI. MyApp_support.py is in the same directory.
    I encountered some problems with packages (i think it was pandas) , because of non referenced dependencies to Qt (???), but it was not a problem due to Page.
    --onedir option works well on local PC, but is slow when used from network.
    --onefile option works, but takes time to open.
    Happy coding :)

    J-Pierre

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.