![]() |
Graphics py not found - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Graphics py not found (/thread-2698.html) Pages:
1
2
|
Graphics py not found - vnc - Apr-03-2017 Windows 10 Python 3.6 copied graphics.py file from link on website but i get an error message: Traceback (most recent call last): File "C:\Users\<user name>\Desktop\w.py", line 2, in <module> from graphics import * ModuleNotFoundError: No module named 'graphics' ...........when running code with import to it. Any ideas? the file is correctly named graphics.py and copied to the ...python\python36\lib\site packages any ideas greatly appreciated? RE: Graphics py not found - metulburr - Apr-03-2017 Quote:...python\python36\lib\site packagesThis resembles the path. lib is capped, site packages is really site-packages the path would something like C:\Python36-32\Lib\site-packages If C:\Python36-32 is where you installed python then that is the path you need to put it. And this has nothing to do with GUI coding so i moved your post. RE: Graphics py not found - snippsat - Apr-03-2017 Do this. >>> import sys >>> sys.pathThe list you get is where Python look for .py files. RE: Graphics py not found - wavic - Apr-03-2017 You can't just put graphics.py in C:\Python36-32\Lib\site-packages. You have to write __init__.py if you want Python to see a directory with some .py files as a package. Even if __init__.py is a completely empty file. Or you can add the direcotory of the graphycs.py to PYTHONPATH environment variable. RE: Graphics py not found - vnc - Apr-04-2017 (Apr-03-2017, 06:00 PM)wavic Wrote: You can't just put graphics.py in C:\Python36-32\Lib\site-packages. You have to write __init__.py if you want Python to see a directory with some .py files as a package. Even if __init__.py is a completely empty file. Thanks I'm sure you are right but being a novice i dont follow the 'write_init_.py' part ..i have no idea what this means. I followed instructions for adding graphics.py from various web sites which stated that the file needs to be placed in the ..\site-packages folder. The supplied readme in that folder also states that 3rd party files/modules need to be placed there..so i'm sure it is in the correct location. The instructions state that this is where Python will be able to 'see it'. I ran the sys.path which output 5 different paths including the one above which is where the file is. if there is a separate procedure for adding the directory i.e to PYTHONPATH env variable i don't know of this ..Ok ..Ive checked the environment variable path which is defined under user variables. I've also added the same path to 'System Variables' but still i get the same error message . graphics not found RE: Graphics py not found - wavic - Apr-04-2017 I have not gotten to that part yet. Writing a module. Don't know what __init__.py should contain. You can try just to create an empty one and put it on the same site-packages/module_name/ directory. See this The PYTHONPATH is part of the system environmental variables. Any program can create their own. This is a list of directories where Python looks for modules or packages. A single .py file could be a module and you can import it like any other: import module_name. If the file has a name module_name.py. But this file have to be in the same working directory or its location have to be in PYTHONPATH. Or you can the location of graphics.py to the PYTHONPAT: import sys sys.path.append("/home/user/my_modules/") RE: Graphics py not found - snippsat - Apr-04-2017 The problem is not with making a module/package wavic. Quote:I ran the sys.path which output 5 different paths including the one above which is where the file is.Then it should work,there most be something else that's going on. Do you only have 1 Python version? Here some test you can run: # Test which python >>> import sys >>> sys.executable 'c:\\python36\\python.exe' >>> exit() # Test pip C:\>pip -V pip 9.0.1 from c:\python36\lib\site-packages (python 3.6) C:\>So making a module as a test(which is just a single python file like graphics.py )#foo_1.py import os print('Running {}'.format(os.path.realpath(__file__)))I place foo_1.py in my 36 site-packages folder.Test that it work: C:\>python Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 07:18:10) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import foo_1 Running C:\python36\lib\site-packages\foo_1.py >>> exit() C:\> RE: Graphics py not found - vnc - Apr-05-2017 I have only the one python version None of the above works and throws syntax errors ...even 'c:\>python' throws a 'unexpected character after line continuation character' error no idea ..myabe i just wasn't supposed to use Python:-( RE: Graphics py not found - snippsat - Apr-05-2017 (Apr-05-2017, 12:05 PM)vnc Wrote: ...even 'c:\>python' throws a 'unexpected character after line continuation character' errorYou are mixing up the use Python interactive shell and cmd Introduction to the Windows Command Prompt(cmd) To make your error and fix it: I start cmd: Microsoft Windows [Version 10.0.14393] (c) 2016 Microsoft Corporation. Med enerett. C:\WINDOWS\system32>cd\ C:\>python Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 07:18:10) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> c:\>python File "<stdin>", line 1 c:\>python ^ SyntaxError: unexpected character after line continuation character >>> exit() # Now i am on command line and not python shell C:\>python -V Python 3.6.0 C:\>pip -V pip 9.0.1 from c:\python36\lib\site-packages (python 3.6) # Start shell again C:\>python Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 07:18:10) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> print('hello world') hello world >>> RE: Graphics py not found - vnc - Apr-05-2017 I get it thanks ..never realised cmd could be used for python. So the above is fine but i still have no idea on how to use use graphics.py. It still can't be accessed ..via the cmd shell either? i.e from graphics import* |