This question already has answers here:
Module 'tkinter' has no attribute 'Tk'
(8 answers)
Closed 2 years ago.
I'm trying to use tkinter in Pycharm but it does not work.
from tkinter import *
fenster = Tk()
fenster.title("Fenster")
fenster.mainloop()`
It also does not work on the terminal, because the error "NameError: name 'Tk' is not defined" occurs.
The tkinter._test() works fine the terminal.
you should not name your file with the same name as your library. in this case change your file name to something else to solve the error.
Related
This question already has answers here:
Cannot install pygame in Pycharm
(1 answer)
pycharm doesn't recognize pygame package
(2 answers)
Closed 2 years ago.
I am trying to install Pygame using Pycharm, but keep getting an error when downloading. It suggests running the command in the terminal, but when I do that it says:
Requirement already satisfied: pygame in /Library/Python/2.7/site-packages (1.9.6)
I don't understand what I am supposed to do at this point so some help would be really nice.
This question already has answers here:
Python - pygame error when executing exe file
(3 answers)
PyInstaller, spec file, ImportError: No module named 'blah'
(3 answers)
Pyinstaller Unable to access Data Folder
(1 answer)
Closed 2 years ago.
I have the following structure in my project:
ProjectFolder/
|- Back/
|-Estadísticas.py
|-FicheroBaraja.py
|- Front/
|-MenuInicial.py
|-MesaJuego.py
|-Pantalla.py
|-PantallaResultados.py
|-PantallaError.py
|-Cartas/
|-Baraja.py
|-CartaBaraja.py
|-Util.py
|app.py
app.py is the module we have to execute to start the program
This project uses pygame, pandas and matplotlib
I have been told by pyinstaller tutorials that in my case I should execute the following command from project folder:
pyinstaller --onefile --paths=./Back --paths=./Cartas --paths=./Front app.py
It generated my executable file in the folder dist.
If I execute it in that folder, it will return an exception because it can't find the module MenuInicial.py (which is called in app.py) so that is logic.
However, when I move the file app.exe generated to the same folder as app.py (to project folder) and I execute it several weird things happen.
First, it takes ages to print the welcome message for pygame
Second, it opens my main window but in black completely
Third, after several seconds the window is closed without any interaction and it does not return any exception, error or anything.
I am doing all of this in Windows 10x64 bits in Spanish.
I tried to do:
sxstrace trace -logfile:trace.log
And got this error:
Error de StartTrace. Mensaje de error: Access Denied
I should be able to run my application according to the documentation I have read.
To sumarize, these are the components I am using:
python 3.7.1
pyinstaller 3.5.dev0+d74052489
Windows 10 (well, this is where I am executing this)
matplotlib 3.0.3
pandas 0.24.2
The weird thing is, pyinstaller finds pandas, pygame and myplotlib and packages them well apparently
This question already has answers here:
Python module not found even though "Requirement Already satisfied in Pip"
(12 answers)
Closed 3 years ago.
I Can't able install filedialog package in python3 it shows already requirement satisfied. The package is installed but not working. Can anyone help me to solve?
You can use Tkinter's askopenfilenames. This is very similar to FileDialog, but with the Tkinter module.
import tkinter
from tkinter import askopenfilenames
root = tkinter.Tk().withdraw()
files = askopenfilenames() #This is the FileDialog window
This question already has answers here:
What are the requirements for naming python modules?
(3 answers)
Closed 4 years ago.
I tried to import the file 227exercise.py, but keep getting following error:
SyntaxError: Invalid Syntax
You can do this with importlib.
import importlib
module = importlib.import_module("227exercise")
print(repr(module))
# <module '227exercise' from '/home/ubuntu/227exercise.py'>
However, it is still strongly recommended that you name your python files with valid identifiers (they can't begin with digits).
This question already has answers here:
Adding a module (Specifically pymorph) to Spyder (Python IDE)
(13 answers)
Closed 6 years ago.
I have installed numdifftools and it works in Python shell. But in Spyder, I get this error which don't know how to solve!
ImportError: No module named 'numdifftools'
on the IPython console within spyder allows you to use pip. So, in the example, you could do:
[1] !pip install numdifftools
All possible answers :
1.For any libraries that you want to add that aren't included in the default search path of spyder (whatever that is) you need to go into Tools and add a path to EACH library via the PYTHONPATH manager. You'll then need to update the module names list from the same menu and restart spyder before the changes take effect.
2.Find the location of a module in Terminal:
$ python #open python
>>> import numdifftools #import a module
numdifftools #get the location of the package
Copy-paste the module folder to the 'Spyder.app/Contents/Resources/lib/python2.7'
Relaunch Spyder.app
3.Try install from ipython(within spyder) : !pip install numdifftools
Refer : similar question