Restoring my tkinter project to funtionality - python

I was working on my project and everything was working perfectly. Suddenly the interpreter is giving the error
from tkinter import _flattern, _join, _stringify, _splitdict
ImportError:cannot import name '_flattern', from 'tkinter' (path to my
file directory)
All of my program files from all projects that i am using tkinter are showing the same error

Related

ModuleNotFoundError: can no longer import my self-made classes from different folders

I am trying to import a self-made class ImportThickness which is saved in a file ImportThickness_full.py from a different folder but I keep getting the error ModuleNotFoundError: No module named 'Data_imports' stating the folder in which this file in which my class is saved does not exist.
I'm trying to import this class in the file merge_all_data.py using the this code:
from Data_imports.ImportThickness_full import ImportThickness
My directory looks as follows:
---Codes
------test
---------merge_all_data.py
------Data_imports
----------ImportThickness_full.py
Can anyone point out where I'm making a mistake?
I don't know if this is of importance but I'm running Python 3.9.12 in Spyder 5.1.5 using Anaconda.

My Tkinter exe App realized can't find my module

i create an app in Python with Tkinter. When I execute this code with Pycharm it works, but after creating the exe i get this error. I load the error screen
I used pyinstaller to create the exe: pyinstaller.exe --onefile --windowed --icon=icona_interfaccia.ico v2_tkinter_robot_gui.py
The app code is divided into four folders, called:
Vision_Code
Interface_Code
Manual_movements_Code (Codice_Manuale)
Kinematics_Code (Codice_Cinematica)
All this four folder are saved in one call Code.
The v2_tkinter_robot_gui.py is the main file, where all the codes I wrote converge and it is saved in the folder called Interface_Code.
To import my modules I use the following wording:
from Codice_Manuale.Movimentazione_manuale import moveJabs, moveJ
#from Codice_Cinematica.cinematica_pallettizzatore import *
#from Codice_Manuale.funzioni_gestione_meccanica import aggiusta_zeri, workspace,
finecorsa_angoli, home_braccio
from Codice_Visione.movimento_ciclo_completo_visione import *
from Codice_Visione.movimento_immediato_visione import *
I had already created an exe on another machine that I no longer have. On this one it worked without problems.
Thanks in advance for the help

How to import a python file inside a folder?

Im having trouble importing a python file that is in the seme directory but on a folder: ./subproject1/subproject1.py
Error:
File "/home/ubuntu4/Downloads/ProjectX/main.py", line 4, in
import subproject1.subproject1
ImportError: No module named subproject1.subproject1
The project looks like this:
/home/ubuntu4/Downloads/ProjectX
-/subproject1
- subproject1.py
main.py
And I import like this on python:
import sys
import os
import multiprocessing
import subproject1.subproject1
I have runned this from my windows PC and it works perfectly and from my ubuntu pc it isn't working, some suggestions?
I think it's a bug since I restarted the computer, without any changes and the problem was solved, when working with a virtual environment in a virtual machine it may have generated a bug

record extension file missing in Xlib

I tried running a linux keylogger called pykeylogger but ran into the following error:
"...from Xlib.ext import record
ImportError: cannot import name record"
I went into the ext directory of Xlib and saw there is no record.py in there. Is there somewhere I can get this file? Also, is there a reason it wouldn't have been installed with the rest of Xlib? I downloaded Xlib from here:
http://python-xlib.sourceforge.net/

Help with Tkinter in py2exe

I'm trying to convert a basic tkinter GUI program to an .exe using py2exe. However I've run into an error using the following conversion script.
# C:\Python26\test_hello_con.py py2exe
from distutils.core import setup
import py2exe
setup(windows=[r'C:\Python26\py2exe_test_tk.py'])
C:\Python26\py2exe_test_tk.py is the following code
import Tkinter as tk
root = tk.Tk()
root.title("Test")
label1 = tk.Label(root,text="Hello!",font=('arial', 10, 'bold'), bg='lightblue')
label1.pack(ipadx=100, ipady=100)
root.mainloop()
This is the error I get when I try to run the newly created .exe
Traceback (most recent call last):
File "py2exe_test_tk.py", line 4, in <module>
File "Tkinter.pyc", line 1643, in __init__
_tkinter.TclError: Can't find a usable init.tcl in the following directories:
{C:/Users/My_Name/lib/tcl8.5} {C:/Users/My_Name/lib/tcl8.5} C:/Users/lib/tcl8.5 {C:/Users/My_Name/library} C:/Users/library C:/Users/tcl8.5.8/library C:/tcl8.5.8/library
This probably means that Tcl wasn't installed properly.
I'm pretty sure it's something in my conversion script thats giving me problems. What did I omit? Or does someone have an example of what the conversion script would look like for a tkinter GUI program? Also is it possible to divert the output .exe files to my desktop?
EDIT:
The error report said that I was missing init.tcl from {C:/Users/My_name/lib/tcl8.5}. So i made that directory and put a copy of init.tcl there. Now when I try to run the .exe it states that MSVCR90.dll is missing from my computer and is needed to run my program.
Also this is python 2.6.5 on Windows 7.
Such errors in Unix world are usually due to incorrect PATH settings or/and incorrectly installed third party modules (the GUI ones you're using). Have you seen this post: py2exe fails to generate an executable ?

Categories