I just installed graphics.py for python.
But when I tried to run the following code:
from graphics import *
def main():
win = GraphWin("My Circle", 100, 100)
c = Circle(Point(50,50), 10)
c.draw(win)
win.getMouse() # Pause to view result
win.close() # Close window when done
main()
my interpreter gave me this strange information:
Traceback (most recent call last):
File "F:\CS 101\Python\projects\packer.py", line 8, in <module>
from graphics import *
File "F:\CS 101\Python\lib\site-packages\graphics.py", line 168, in <module>
_root = tk.Tk()
File "F:\CS 101\Python\lib\tkinter\__init__.py", line 1674, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: Can't find a usable init.tcl in the following directories:
{F:\CS 101\Python\tcl\tcl8.5.9} {F:/CS 101/Python/tcl/tcl8.5} {F:/CS 101/Python/lib/tcl8.5} {F:/CS 101/lib/tcl8.5} F:/lib/tcl8.5 {F:/CS 101/library} F:/library F:/tcl8.5.2/library F:/tcl8.5.2/library
F:/CS 101/Python/tcl/tcl8.5/init.tcl: version conflict for package "Tcl": have 8.5.2, need exactly 8.5.9
version conflict for package "Tcl": have 8.5.2, need exactly 8.5.9
while executing
"package require -exact Tcl 8.5.9"
(file "F:/CS 101/Python/tcl/tcl8.5/init.tcl" line 20)
invoked from within
"source {F:/CS 101/Python/tcl/tcl8.5/init.tcl}"
("uplevel" body line 1)
invoked from within
"uplevel #0 [list source $tclfile]"
This probably means that Tcl wasn't installed properly.
What does it mean?
What can I do?
PS: I am using Eclipse (PyDev) for coding.
I sloved by modifying my activate script:
set "TCL_LIBRARY=D:\Program Files (x86)\Python3.5\tcl\tcl8.6"
set "TK_LIBRARY=D:\Program Files (x86)\Python3.5\tcl\tcl8.6"
Regarding what you can do, you can try editing your init.tcl file to read something like package require Tcl 8.5.0-8.6, or if that doesn't work you can try package require -exact Tcl 8.5.2. I also had to edit my tcl\tk8.5\tk.tcl file in the same way, for Tk instead of Tcl.
If editing the file does not work for you, you can download and install the latest Tcl from:
source using the latest version from sourceforge. This will require having an acceptable compiler. For example, see blog.victorjabur.com/2011/06/05/compiling-python-2-7-modules-on-windows-32-and-64-using-msvc-2008-express/ or stackoverflow.com/questions/4218613/building-a-python-module-on-windows-using-ms-compiler.
the latest ActiveState community version. This may be the easiest option if you have permission to install. Seeing that this is for CS 101, your lab administrators might not allow you that permission (whether by policy or technology). Of course, that also probably means this answer comes too late to help with your immediate need.
Regarding what it means, without more information, I can only make conjectures right now. I had the reverse problem; I will tell you about it in hopes that it gives you some insight into what it might mean.
I have 8.5.9 installed, but init.tcl was requiring 8.5.2. I'm guessing my problem was caused by installing ActiveState python, then official python (both 2.7, 64-bit), and/or additional packages I installed later. There is a note at the bottom of this download page regarding Tcl/Tk on MacOS that one could interpret to mean there is room for trouble on the PC as well. ActiveState Python 2.7 includes Tcl/Tk 8.5.9, as documented here. Using 7-zip to open the msi files from ActiveState and Python.org, and grepping for "tcl" and then "require", I can see that the init.tcl in the ActiveState msi specifies package require -exact Tcl 8.5.9.
My guess is that the 8.5.2 requirement came from the regular python install (which is apparently less grepable), or some package I installed later. Running the ActiveState msi in repair mode does not fix the issue, nor does running the Python msi in repair mode.
P.S If this isn't timely, why did I still answer? Crafting a decent answer for you helped me understand my issue better.
I am running PyCharm IDE with Python 2.7.
Inside c:\Python27\tcl\tcl8.5\init.tcl "package require -exact Tcl 8.5.2" change to
package require -exact Tcl 8.5.9
Inside c:\Python27\tcl\tk8.5\tk.tcl "package require -exact Tk 8.5.2" change to:
package require -exact Tcl 8.5.9
This worked for me.
I faced the same problem during my last installation of ns2.35 in ubuntu 11.04.
After I install ns2.35, got message of successful installation of ns. Then I set path in /.bashrc. Then I gave ns command which gave me same error which you got.
The problem is because, ns executable is also at /usr which is conflicting.
Solution:
Go to location root-usr-local-bin by giving following command in terminal
cd /usr/local/bin
There you would find the ns file. We just need to remove it by giving following command
rm ns
Thats it, you are done. Now your ns starts running successfully.
There maybe a compatibility issue with another program that uses the TCL_Library environment variable. In the attached thread I changed the environment variable path and it fixed my issue. It may be relevant to your problem:
Python IDLE won´t start
The PATH solution did't work for me. I'm using Win7 python 2.7.
Finally I edited 2 files:
C:\Python27\tcl\tk8.5\tk.tcl
package require -exact Tk 8.5.2
change into
package require Tk 8.5.0-8.6
C:\Python27\tcl\tcl8.5\init.tcl
package require -exact Tcl 8.5.2
change into
package require Tcl 8.5.0-8.6
And this works! Previously my IDLE never pops out, but now it works as well. Cool, thanks #Jonathan Spooner and #hlongmore
I think I had the very same problem under windows8/python2.7. It was a hell of installations and env variables setting. All of them worthless. Today I've found a solution:
Downloading and installing python at D: (in order to preserve my installation) and then copying the folder Tcl into my C: installation in the same relative position: C:\Python27
To give a more general solution, in the error traceback, you should have something like:
C:/Users/[perso path]/tcl/tcl8.6/init.tcl: version conflict for package "Tcl": have 8.6.6, need exactly 8.6.8
version conflict for package "Tcl": have 8.6.6, need exactly 8.6.8
So just open the file described in the error: C:/Users/[perso path]/tcl/tcl8.6/init.tcl and replace package require -exact Tcl 8.6.8 with the version needed in the error, for me it was 8.6.6: package require -exact Tcl 8.6.6.
Then the same problem will happen with Tk (with another file), I did the same operations and it worked. Maybe you won't have the same versions, just replace them.
I had a similar problem when generating a simple scatter plot using mayplotlib.pyplot in Windows 10. I solved by adding the new environment variables in
Control Panel>System and Security>System>Advanced system settings>Environment Variables>User variables for UserName:
Variable Name: TCL_LIBRARY, Variable value=C:\Python27\tcl\tcl8.5
Variable Name: TK_LIBRARY, Variable value=C:\Python27\tcl\tk8.5
Related
Just working my way through a (very good) book call Test Driven Development using Python.
This makes use of Python3.4 by the way. By the way, I am running in a Windows 7 OS.
I've got all the stuff working using a simple text editor and running from the command line... in the course of which in particular I used "pip install" to install Django and Selenium, as per book's instructions.
This created folders "selenium" and "django" under ...\Python34\Lib\site-packages\ ... so I added these to the PythonPath for my Eclipse/PyDev project.
With the correct interpreter selected I then tried to run a file which runs fine on the command line: "> python3 functional_tests.py"... but I get
File "D:\apps\Python34\lib\site-packages\django\http\__init__.py", line 1, in <module>
from django.http.cookie import SimpleCookie, parse_cookie
File "D:\apps\Python34\lib\site-packages\django\http\cookie.py", line 5, in <module>
from django.utils.six.moves import http_cookies
ImportError: cannot import name 'http_cookies'
... to me this looks like a dependency thing... as though "pip install" handles dependency matters in a way just including a single folder doesn't.
Question boils down to this: what's the "proper" way to install a python module using PyDev?
several days later
wow... nothing? Nothing! I suppose this must mean that you either have to add dependencies manually or use something like Ant, Maven or Gradle within Eclipse itself. These latter are not my strong areas, even outside an IDE. Would still be nice to have an answer from a PyDev expert!
Well, pip install should work for PyDev (it should automatically recognize the dependency)...
I.e.: in your use case, the only folder that should be in the PYTHONPATH is D:\apps\Python34\lib\site-packages (and pip should install packages to that folder -- make sure you don't add extra folders for "D:\apps\Python34\lib\site-packages\django" nor anything else inside the site-packages to the PYTHONPATH).
If it's still not working, please check if the module django.utils.six.moves.http_cookies is indeed where you expect it to be. Also, you can print the PYTHONPATH being used in runtime with:
import sys
print('\n'.join(sorted(sys.path)))
To check if that's really what you expect.
After a couple days I returned to my computer and noticed my graphing scripts no longer works, despite no changes being made to the graphing code or the computer libraries. I decided to investigate and the example script from here no longer works and throws this error
objc[34475]: Class TKApplication is implemented in both /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk and /Library/Frameworks/Tk.framework/Versions/8.6/Tk. One of the two will be used. Which one is undefined.
objc[34475]: Class TKMenu is implemented in both /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk and /Library/Frameworks/Tk.framework/Versions/8.6/Tk. One of the two will be used. Which one is undefined.
objc[34475]: Class TKContentView is implemented in both /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk and /Library/Frameworks/Tk.framework/Versions/8.6/Tk. One of the two will be used. Which one is undefined.
objc[34475]: Class TKWindow is implemented in both /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk and /Library/Frameworks/Tk.framework/Versions/8.6/Tk. One of the two will be used. Which one is undefined.
Upon the import mentioned below and the following fatal error uport running Tk.Tk()
Traceback (most recent call last):
File "/Users/username/Desktop/Projects/name/test.py", line 20, in <module>
root = Tk.Tk()
File "/usr/local/Cellar/python3/3.3.3/Frameworks/Python.framework/Versions/3.3/lib/python3.3/tkinter/__init__.py", line 1789, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError
I'm confused why is it pointing to my Brewed (I'm on Os X if this helps) python if I'm working in a virtual environment. It is worth noting that Tkinter and Matplotlib work separately, It's just the line
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
that breaks stuff.
EDIT1: I tired reinstalling Tcl, python and virtualenv. Nothing fixed the problem :(
EDIT2: Run the same thing in a python2 (innsted of 3) interpreter. Error was more verbose.
/Library/Frameworks/Tk.framework/Resources/Scripts/tk.tcl: version conflict for package "Tcl": have 8.5.9, need 8.6
version conflict for package "Tcl": have 8.5.9, need 8.6
while executing
"package require Tcl 8.6"
(file "/Library/Frameworks/Tk.framework/Resources/Scripts/tk.tcl" line 14)
invoked from within
"source /Library/Frameworks/Tk.framework/Resources/Scripts/tk.tcl"
("uplevel" body line 1)
invoked from within
"uplevel #0 [list source $file]"
This probably means that tk wasn't installed properly.
Ok so problem is to do with the Tcl thing. Which I haven't touched and it worked prevoiusly.
EDIT3: Tried a reinstall of ActiveTcl - did not change anything
EDIT4: under /System/Library/Frameworks/Tk.framework/Versions/ I have Tk versions 8,5 and 8.4 installed
under /Library/Frameworks/Tk.framework/Versions/ I have version 8.6 installed.
I tried disabling version 8.6 to reflect the configuration on a different computer the script works on. Got this error:
ImportError: dlopen(/Users/mik/Desktop/Projects/ODE/virtenv/lib/python3.4/site-packages/matplotlib/backends/_tkagg.so, 2): Library not loaded: /Library/Frameworks/Tcl.framework/Versions/8.6/Tcl
Referenced from: /Users/mik/Desktop/Projects/ODE/virtenv/lib/python3.4/site-packages/matplotlib/backends/_tkagg.so
Reason: image not found
Both computers use same Python version (3.4.1) and the same matplotlib version (1.3.1). Is there a way to specify which Tk/Tcl version matplotlib uses?
EDIT 6: I verified using Time Machine that none of the Tk/Tcl veriosn files changed since the last time the script ran.
EDIT 7: And kinda solution:
Copying the matplotlib folder from site-packages of the working computer to the one which displays those errors fixed the issue. I would be grateful to know how to set the tcl version used by matplotlib in the future.
I found a solution. Matplotlib looks for the Tcl/Tk framework when its being installed. I temporarily disabled version 2.6, reinstalled matplotlib and re-enabled version 2.6. Works
I just installed ycm, everything looks good, but I found small problem. The problem is as following:
import os # os is built-in library
os. # ycm helps to complete members of the class.
import numpy # numpy is not built-in library, where its location is site-packages.
numpy. # nothing happened. ycm shows 'pattern not found' message.
I think, this would be a simple problem. But I could not find the solution yet. I think, there is some configuration file in which I can define 'search path' for my project.
It would be grateful if I can find a way to solve it.
Best,
Je-Hoon Song
I had the same issue with module 'mpmath' and fixed it in the following manner:
First I retrieved the path where the module was located:
%python3
>>>import mpmath
>>>print(mpmath.__file__)
/usr/lib/python3.4/site-packages/mpmath/__init__.py
Here I found the path of all my "installed" python3 packages to be:
/usr/lib/python3.4/site-packages/
I then simply added to my PYTHONPATH environment variable this path:
%export PYTHONPATH=/usr/lib/python3.4/site-packages/
Then when I used vim sample.py typing import mpmath and following it up with mpmath. YCM showed me all the autocompletions for the mpmath module.
Hope this helps.
I use anaconda python to be my python interpreter in ycm to solve this.
First I modified my vimrc according to full pythong setting in vim.
Then I change g:ycm_python_interpreter_path by
let g:ycm_python_interpreter_path = '/usr/local/anaconda3/bin/python3.8'
In this way I didn't change the system environment variables.
Addtional Info 1:
I think the main problem is that,
my Python interpreter for YCM is my system python (/usr/local/opt/python#3.9/bin/python3.9 ),
which only has limited locally built libraries.
So using the libraries comes with anaconda (/usr/local/anaconda3/bin/python3.8 ) can solve.
Additional Info 2:
By reading :YcmDebugInfo, the main different after edited g:ycm_python_interpreter_path is that:
-- Python completer debug information:
-- Python interpreter: /usr/local/opt/python#3.9/bin/python3.9
-- Python path: ['/usr/local/Cellar/python#3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python39.zip', '/usr/local/Cellar/python#3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9', '/usr/local/Cellar/python#3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload', '/usr/local/lib/python3.9/site-packages']
-- Python version: 3.9.6
change to
-- Python completer debug information:
-- Python interpreter: /usr/local/anaconda3/bin/python3.8
-- Python path: ['/usr/local/anaconda3/lib/python38.zip', '/usr/local/anaconda3/lib/python3.8', '/usr/local/anaconda3/lib/python3.8/lib-dynload', '/usr/local/anaconda3/lib/python3.8/site-packages', '/usr/local/anaconda3/lib/python3.8/site-packages/aeosa', '/usr/local/anaconda3/lib/python3.8/site-packages/locket-0.2.1-py3.8.egg']
-- Python version: 3.8.8
Additional Info 3: about how to read list of locally installed pyton modules
use https://stackoverflow.com/a/740018/11226687
e.g. in my case
$ /usr/local/opt/python#3.9/bin/python3.9
>>> help('modules')
# only return limitted modules
$ /usr/local/anaconda3/bin/python3
>>> help('modules')
# list out all the modules included in Anaconda, including numpy/matplotlib/scipy ect
numpy is kind of a difficult library because it dynamically builds its namespace on import, making it hard for static code analysis tools to know when you're write the code what names should be available. Because the names available in the namespace numpy are only really known at runtime, YCM probably doesn't have any useful suggestions for you.
One simple way to fix is activate your python environment, then open vim. For example
(django_mdn) ➜ locallibrary git:(master) ✗ vim
and in the vim run :echo $PATH.
Then you should be able to see that your venv path is at the first like this:
/Users/gwanghyeongim/.virtualenvs/django_mdn/bin:/usr/local/opt/tcl-tk/bin:...
Then see if your python packages are auto-complete.
It worked.
If you want to set a certain site-packages to be auto complete permanently, you need to make a file called .ycm_ extra_conf.py in your project root directory or global_extra_conf.py and set vim configuration if you want to set it globally.
P.S.
By running export PYTHONPATH=/usr/lib/python3.4/site-packages/ in the shell before opening vim didn't work for me. Besides, unless setting PYTHONPATH permanently, which will cause issue, you will have to set export PYTHONPATH everytime you want dependencies to be auto complete.
I'm getting this error every time I run any python file in Eclipse using PyDev:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/site.py", line 73, in <module>
__boot()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/site.py", line 2, in __boot
import sys, imp, os, os.path
ImportError: Bad magic number in /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/os.pyc
I'm using python 2.6. This problem does not occur when I run python from the terminal (2.7 or 2.6). The only substantial thing I've changed since everything last worked, is an update to OSX Lion from Snow Leopard.
Similar discussions to this seem to suggest some kind of removal of the .pyc file, because of some kind of mismatch between what was originally using the .pyc files (I'm not entirely sure what a magic number is...). But I was a bit cautious of the idea of deleting os.pyc from the Frameworks directory. When the only other file is an os.pyo file (not sure what the difference it), rather than an os.py.
I've installed all OSX Lion updates, Eclipse updates and PyDev updates.
This problem occurs even with code such as :
if __name__ == '__main__':
pass
Any help resolving this would be appreciated!
Upgrading Python to 2.7.1, running "Update Shell Profile" command file which is located in Python directory and changing the Python settings in Netbeans according to new installation worked for me.
Yeah, you'll need to regenerate all your *.pyc and *.pyo files from the *.py files.
How you do this depends on how they were generated in the first place. Some packaging of python (and it's add-ons), such as in some Linux distros, gets a little too clever for its own good and keeps the original *.py files somewhere else and have their own build system for generating and placing the *.pyc and/or *.pyo files. In a case like that, you have to use that build system to regenerate them from the original *.py files.
FYI, here are a couple links on *.pyo files. They are the optimized versions of compiled python modules.
On OS X Lion, you should have a os.py file. This is likely the root cause of your error. The os.pyc file was generated from a different version of python than you are running now. Normally, I imagine the python interpreter would just regenerate the file from os.py. But for whatever reason, your system does not have that file.
I suspect that this is a small data point in a larger set of issues and would, in general, recommend a reinstallation of your operating system.
For comparison, I'm running 10.7.1, and I have the following:
[2:23pm][wlynch#orange workout] ls /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/os.*
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/os.py
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/os.pyc
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/os.pyo
As an aside, the *.pyo file is an optimized version of the python bytecode.
I'm typing at the console
from graphics import *
and I get this error
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
from graphics import *
ImportError: No module named graphics
I think your question comes from trying to work through Python Programming by John Zelle, with a Macintosh.
The first 4 chapters are great. But in chapter 5, where I tended to get stuck, he introduces Objects. The way he does that is kind of interesting. He has created a python module which he calls “graphics.py” which you can download from his website.
This module (I’ve attached a link to it below) is a python program written by Mr. Zelle. It creates the tools for making very simple shapes and getting used to the basic concepts with graphics and it also serves as a more tangible way of introducing Objects.
However I was confused, it took me a while to realize that “graphics.py” was a pedagogical program Mr. Zelle created, and not something that comes bundled with MacPython. This confusion stems from the fact that the programs in Chapter 5 all begin with “import graphics” which looks very similar to the “import math” command at the beginning of every program in the 3rd chapter.
The key difference is that “import math” imports the standard mathematics library that came pre-bundled with MacPython. But “import graphics” refers to John Zelle’s own “graphics.py” module, which you have to download and instal first.
It took me a while to figure that out….
Then once I did, I went to his website, copied the program from this website:
http://mcsp.wartburg.edu/zelle/python/graphics.py
...into IDLE and then saved it as graphics.py
This is where it got maddening...
On Windows if you just put the graphics.py file in the same folder as Python, it can find the file and use it without a problem.
Here is what the book said, that made me feel so crazy:
“To use the graphics module (graphics.py) you need to place this file where Python can locate it. >One simple approach is to put it in the same folder where you keep your Python programs. Starting >Python in this folder will also let you import the graphics library to experiment interactively.
Alternatively, you can place the graphics.py file in a system-wide directory so that it is >available for import no matter what directory Python starts in. The standard directory for placing >local additions to Python is the site-packages directory. On my Windows installation, the complete >path to the folder is:
C:\Python23\Lib\site-packages
On my Linux system, the file resides in:
/usr/local/bin/lib/python2.3/site-packages."
On a windows OS, all that you have to do is go to Python.org and download Python for Windows and put that graphics.py file in the main folder, and boom, you’re golden, NOT SO FOR MACINTOSH!!!!
2 years ago, this is where I got totally stuck, because I had no idea about site paths, or directories; I just pointed and clicked; I didn’t know about the Unix system underneath the Macintosh Aqua GUI.
And the book gives no instructions for what to do if you have a Macintosh, and I hit a wall.
But when I went at it again a few weeks ago, those directories made more sense to me, because I spent the spring and summer playing with a guidebook to using the UNIX command shell on my Mac.
So I realized that my problem had nothing to do with Tkinter, It was just that graphics.py needed to be in the right directory. I couldn’t just put it in the folder next to IDLE as I could on a Windows machine. I needed to find the right directory.
Since OSX is built on a UNIX base, I thought that the file path might be the same as Linux. Sadly, there was no “local”, “bin” after the “user” directory. But its not quite the same in OSX.
Instead you can use IDLE itself to find out which path directories it uses.
You type this:
import sys
print sys.path
and BOOM, it spits out a whole bunch of directories, confusingly formatted like this
['', '/Users/jamesbarnard/Documents', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages’,
'/Library/Python/2.7/site-packages’]
But when I looked closer I noticed the directory “site-packages” which looked a lot like the “site-packages” on the Linux and Windows command lines.
So I pulled out that directory chain
['', '/Users/jamesbarnard/Documents', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload’,
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages', ‘
/Library/Python/2.7/site-packages’]
Then using the UNIX shell I followed it down, and then I did the same thing in the Aqua interface.
And there, buried 8 levels down in the directory, amidst hundreds of other files, I placed my graphics.py file.
Then I went back into IDLE, typed in “import graphics”
AND IT WORKED!!
If you are having this problem. I hope this solution saves you my headache.
did you follow the instructions to install the graphics module and is it in your pythonpath?
Type how to install graphics.py in Google.
http://www.google.co.in/search?sourceid=chrome&ie=UTF-8&q=how+tooinstall+gaphics.py#sclient=psy-ab&hl=en&source=hp&q=how+to+install+gaphics.py&pbx=1&oq=how+to+install+gaphics.py&aq=f&aqi=&aql=&gs_sm=s&gs_upl=0l0l0l24645l0l0l0l0l0l0l0l0ll0l0&bav=on.2,or.r_gc.r_pw.r_cp.,cf.osb&fp=344adf6de4d60025&biw=1366&bih=600
Click on the third link
http://mcsp.wartburg.edu/zelle/python/graphics.py
Copy that file which got downloaded to your lib folder in Python32 in C drive.
The error will not occur now.
Short cut to installing graphics.py via command line and/or terminal window. run the following command in admin rights in windows.
this will allow you to import graphics
pip3 install --user http://bit.ly/csc161graphics
ps. Im running python 3.6.2 on Atom. Hope this helps some.
Perhaps you forgot to run python setup.py -install after downloading the module.
You can also put graphics.py in the same folder where you started the python shell.
http://mcsp.wartburg.edu/zelle/python/graphics.py
I recently had this issue where I typed (and pasting the code into the interpreter did not work either) 'import graphics' into the interpreter and the error I got was:
Traceback (most recent call last):
File "", line 1, in
from graphics import *
ImportError: No module named graphics
I took the following steps to fix the error:
-Go to: http://mcsp.wartburg.edu/zelle/python/
-Right click on the link 'graphics.py and click 'save target as'
-save in the directory 'Python33', along with the 'chaos.py' file. This step is important that you do not save it in other locations (it may work if you save it in other locations I decided to save it in this location).
Hope this helps.