Python Idle Import Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow importerror no module named python the company Business Learn more about hiring developers or posting ads with us Stack Overflow
Importerror Python Cannot Import Name
Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of python importerror 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Module import error using IDLE up vote 0 down vote favorite I'm an absolute beginner using IDLE (Python importerror: no module named pycharm 2.6.4) to learn the basics. I recently found a Python program that I want to run but it throws an error although the code looks fine (i.e all modules exist): from css.parse import parse data = """ em { padding: 2px; margin: 1em; border-width: medium; border-style: dashed; line-height: 2.4em; } p { color: red; font-size: 12pt } p:first-letter { color: green; font-size: 200% } p:first-line { color: blue }""" for rule in parse(data):
$pythonpath
print rule for decl in parse(data)[0]: print decl Error: ImportError: No module named parse How do I fix this? I'm using Snow Leopard. Edit: I guess its a PATH issue, where should I place the modules, which directory? python path python-idle share|improve this question edited May 18 '10 at 5:34 HostileFork 20.6k654104 asked Nov 21 '09 at 3:55 3zzy 19.1k64186315 add a comment| 2 Answers 2 active oldest votes up vote 1 down vote accepted You should have your test.py script in the same folder as the folder, not in the folder. So it should look like this: ../ test.py css/ share|improve this answer edited Nov 21 '09 at 4:14 answered Nov 21 '09 at 3:57 Alvin Row 3,20811435 Yes it does. I guess its a PATH issue which I don't quite understand. –3zzy Nov 21 '09 at 4:00 Can you post the link to this program? –Alvin Row Nov 21 '09 at 4:02 code.google.com/p/css-py –3zzy Nov 21 '09 at 4:05 1 You'll need to install this library: pypi.python.org/pypi/ply/3.1 –Alvin Row Nov 21 '09 at 4:19 1 Could be a bug, ask for help here code.google.com/p/css-py/issues/list –Alvin Row Nov 21 '09 at 4:31 | show 5 more comments Did you find this question interesting? Try our new
here for a quick overview of the site Help Center Detailed answers to any questions you might have python importerror no module named site Meta Discuss the workings and policies of this site About Us python no module named error Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with
__init__.py File
us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just http://stackoverflow.com/questions/1774453/module-import-error-using-idle like you, helping each other. Join them; it only takes a minute: Sign up importing a module in Idle shell up vote 3 down vote favorite 1 I'm trying to learn python and I'm having trouble importing a module. I have a .pyc file that I'm trying to import into idle shell called dfa.pyc I have http://stackoverflow.com/questions/7971744/importing-a-module-in-idle-shell the file in a folder called xyz. I navigate to this folder using: os.chdir('/Users/xxx/Desktop/xyz') So now, if I try to run the command: from dfa import * i get the error: ImportError: No module named dfa If i run the command: os.path.isfile('dfa.pyc') it returns true. Can someone explain how i can get the dfa.pyc file imported? Thanks python python-3.x pyc share|improve this question asked Nov 1 '11 at 19:27 android_student 5641720 1 What's the value of sys.path? –David Z Nov 1 '11 at 19:28 ['/Users/xxx/Documents', '/Library/Frameworks/Python.framework/Versions/3.2/lib/python32.zip', '/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2', '/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/plat-darwin', '/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/lib-dynload', '/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages'] Is this what you're asking for? That's the value i get if i run the sys.path command. THanks –android_student Nov 1 '11 at 19:37 stackoverflow.com/questions/279237/…, try these suggestions? –John Nov 1 '11 at 19:42 add a comment| 2 Answers 2 active oldest votes up vote 7 down vote accepted I don't think python modules are loaded I based on what you do with chdir. Modules are loaded from the folder you st
On Rails HTML5 & CSS Python Modules and IDLE (Import, Reload, exec) - 2016 bogotobogo.com site search: bogotobogo.com site search: Modules - Basics Module Imports/Reloads Every file of Python code with .py extension http://www.bogotobogo.com/python/python_modules_idle.php is a module. Other files can have an access to the items a module defines by importing that module. The import operations load another file and give access to that file's contents through its attributes. bogotobogo.com site search: bogotobogo.com site search: Importing x module makes all of its functions and attributes available. sys.path is a list of directory names that constitute the current search path: >>> sys.path ['', no module 'C:\\Python32\\Lib\\idlelib', 'C:\\Windows\\system32\\python32.zip', 'C:\\Python32\\DLLs', 'C:\\Python32\\lib', 'C:\\Python32', 'C:\\Python32\\lib\\site-packages'] >>> Python will look through these directories for a .py file whose name matches what we're trying to import. In fact, because not all modules are stored as .py files, and some are built-in modules, they are actually baked right into Python itself. Built-in modules behave just like regular modules, but their Python source code is not available, because they are no module named not written in Python but written in C. Once we import a module, we can reference any of its public functions, classes, or attributes. We access its functions with module.function. This module-based services model turns out to be the core idea behind program architecture in Python. Larger programs have multiple module files. One of the modules is designated as the main or top-level file, and this is the one launched to start the entire program. Import operations run the code in a file that is being loaded as a final step. Because of this, importing a file is yet another way to launch it. For example, if we start an interactive session, we can run the script1.py file we created with a simple import. C:\workspace> python >>> import script1.py win32 31.6385840391 blah blah blah This works, but only once per session by default. After the first import, later imports do nothing, even if we change and save the module's source file again in another window: C:\workspace> python >>> import script1 win32 31.6385840391 blah blah blah >>> import script1 >>> import script1 >>> This is by design. Imports are too expensive to repeat more than once per file, per program run. I