0

Hey Guys I know this has been asked before, and even various times, but I can't really figure out the exact problem with regards to my issue, even after looking at the other import errors. It's a really basic question, so sorry for that...

I'm writing a program, we'll call it "X.py". I need to import from another file, named graphics.py so my first line of code says:

from graphics.py import *

I'm pretty sure the rest of my code is right, but when I run the program it gives me the error saying

Traceback (most recent call last):
 File "/Users/me/Desktop/X.py", line 1, in <module>
 from graphics import *
ImportError: No module named 'graphics'

Now I clearly have this file downloaded and I put them in a folder called Project X, together.

Any idea how I can get this program to see the other file I guess? Thanks in advance!

Ashwini Chaudhary
252k60 gold badges479 silver badges520 bronze badges
asked Apr 28, 2013 at 19:26
4
  • 2
    file extension is not included in module statements: from graphics import *. Though your error suggests you used the right syntax but python was not able to find graphics because it's not in the module search path. Commented Apr 28, 2013 at 19:28
  • a note:I hope you're aware that star import are discouraged. Commented Apr 28, 2013 at 19:37
  • what's the location of two files? Commented Apr 28, 2013 at 19:42
  • x.py is on your desktop, not in a folder called Project X. Is graphics.py on your desktop also? Commented Apr 28, 2013 at 19:51

2 Answers 2

2

Drop the .py

Instead, use:

 from graphics import *
answered Apr 28, 2013 at 19:28
Sign up to request clarification or add additional context in comments.

4 Comments

Looking at the traceback it looks like he used the correct syntax in his program.
Yeah sorry I didn't format it properly. I did try modifying the name, but the file still isn't being called...
Where are you getting this graphics.py file? I'll try to replicate on this end.
Well I download the file from a website and then am essentially trying to use it to build a house using 5 clicks and I need it for colors and what not...
0

You have to download this file and put it in the same folder with your script. From the docstring:

INSTALLATION: Put this file somewhere where Python can see it.

answered Jan 27, 2017 at 13:24

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.