module 'tkinter' has no attribute 'tkinter'? [duplicate] - python

This question already has answers here:
tkinter woes when porting 2.x code to 3.x, 'tkinter' module attribute doesn't exist
(1 answer)
Substitute for tkinter.dooneevent
(1 answer)
Closed 4 years ago.
I'm using Python3, I have a program written in Python2, I converted to Python3 using 2to3 command.
After running the code an error had occurred:
AttributeError: module 'tkinter' has no attribute 'tkinter'
Traceback (most recent call last):
File "pacman.py", line 679, in <module>
args = readCommand( sys.argv[1:] ) # Get game components based on input
File "pacman.py", line 567, in readCommand
import graphicsDisplay
File "graphicsDisplay.py", line 15, in <module>
from graphicsUtils import *
File "graphicsUtils.py", line 294, in <module>
def keys_pressed(d_o_e=tkinter.tkinter.dooneevent,
AttributeError: module 'tkinter' has no attribute 'tkinter'

Related

No module named 'rec_rc' [duplicate]

This question already has answers here:
ImportError: No module named 'resource_rc'
(5 answers)
Closed 7 months ago.
I converted QT .ui file into .py file and when I run it I get this error?
Traceback (most recent call last):
File ~\Desktop\Project\main2.py:14 in <module>
from ui3 import Ui_Form
File ~\Desktop\Project\ui3.py:39 in <module>
import rec_rc
ModuleNotFoundError: No module named 'rec_rc'
The following solution if provided by eyllanesc in this question, and it seems to be the same error as yours.
You should have a file called rec.qrc, this must be converted to
.py, this or you can do it by executing:
pyrcc5 rec.qrc -o rec_rc.py

AttributeError: module 'pyautogui' has no attribute 'size' [duplicate]

This question already has answers here:
Importing installed package from script with the same name raises "AttributeError: module has no attribute" or an ImportError or NameError
(2 answers)
Closed 2 years ago.
As a beginner in Python, I really don't know what I'm doing wrong here?
I would like to work with pyautogui:
>>> import pyautogui
>>> pyautogui.PAUSE = 1
>>> pyautogui.FAILSAFE = True
>>> pyautogui.size()
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
pyautogui.size()
AttributeError: module 'pyautogui' has no attribute 'size'
Don't know why it doesn't show my resolution? And in general, pyautogui doesn't work with commands like:
>>> pyautogui.moveTo(100, 100, duration=0.25)
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
pyautogui.moveTo(100, 100, duration=0.25)
AttributeError: module 'pyautogui' has no attribute 'moveTo'
>>>
I'm sure I installed pip.
Your own script which is named "pyautogui.py" is interfering with the module you installed — so rename it something else.

AttributeError: module 'random' has no attribute 'randint' [duplicate]

This question already has answers here:
random module error when run as .py
(3 answers)
Importing installed package from script with the same name raises "AttributeError: module has no attribute" or an ImportError or NameError
(2 answers)
Closed 4 years ago.
Code:
import turtle
import random
turtle.penup()
for i in range(20):
x=random.randint(-200,200)
y=random.randint(-200,200)
turtle.setposition(x,y)
turtle.dot()
turtle.done()
Error:
F:\Python>random.py
Traceback (most recent call last):
File "F:\Python\random.py", line 2, in <module>
import random
File "F:\Python\random.py", line 5, in <module>
x=random.randint(-200,200)
AttributeError: module 'random' has no attribute 'randint'
Rename your file.
Make sure that no files are named random.py.

Error when importing urllib [duplicate]

This question already has answers here:
Importing installed package from script with the same name raises "AttributeError: module has no attribute" or an ImportError or NameError
(2 answers)
Closed 5 years ago.
When I import urllib.request in python 3, I get the following error:
Traceback (most recent call last):
File "urllibExample.py", line 1, in <module>
import urllib.request
File "/home/andrew/Python/urllib.py", line 1, in <module>
import urllib.request, urllib.parse, urllib.error
ModuleNotFoundError: No module named 'urllib.request'; 'urllib' is not
a package
I'm not sure why I'm getting this error message since urllib.request is in the standard library. Does anyone know how to fix this?
You appear to have a file of your own named urllib.py. The import is being attempted from this file instead of the system installed one.
Rename your file.

Module appears in module list but can't be imported [duplicate]

This question already has answers here:
ImportError: No module named _ssl
(9 answers)
Closed 9 years ago.
I'm getting an error because the ssl module isn't available
If I run help('modules') from the python interpreter it is listed there
When I try to import it from the interpreter, I get
>>> import ssl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/ssl.py", line 60, in <module>
import _ssl # if we can't import it, let the error propagate
Ensure that you have openssl package installed.

Categories

Resources