This question already has an answer here:
Python ImportError: cannot import name itemgetter
(1 answer)
Closed 2 years ago.
When I tried in Mac os with python 3.8.3
this code:
from turtle import *
shape("turtle")
I get this error:
Traceback (most recent call last):
File "C:\Users\jeeva\Desktop\Tanmay_new\python\pi\Draw_pi\draw_pi.pyw", line 2, in <module>
shape("turtle")
NameError: name 'shape' is not defined
It looks like python doesn't reconize shape.
Please help me.
See if you have a file named turtle.py other than the module. Rename it and try again
Related
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
This question already has answers here:
Why can't I import from a module alias?
(4 answers)
Closed 2 years ago.
Let's suppose I import the pathlib module with an alias :
import pathlib as plib
Then plib is now pointing to the pathlib module :
>>> plib
<module 'pathlib' from '/usr/lib/python3.8/pathlib.py'>
Now can someone tell me why importing something from this aliased module doesn't work?
>>> from plib import Path
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'plib'
The loading process of The module is not based on the alias, it searches the python installation or project directory by the given name after import statement.
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.
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.
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.