Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
Can't import modules
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Steven D'Aprano, post: 5052910"] I would say that the two things you are doing wrong are, firstly, not posting the ENTIRE error message, including the full traceback, and most importantly, not paying attention to what Python is trying to tell you. The full traceback gives import information. For example: py> import foo Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named 'foo' Note carefully that Python tells you the *kind* of error made: an IMPORT error, as well as a specific error message, namely that there is no module called "foo". Python will often print the actual line causing the error as well. In your case, my guess is that this is your error: py> import math py> math(123) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'module' object is not callable Notice that the import succeeds. So it is *incorrect* that you cannot import modules, but once you import them, you use them incorrectly! Python tells you exactly what went wrong, if you would only pay attention to it: * it is a TYPE error, not an import error; * modules cannot be called as if they were a function Does this solve your problem? If not, please: * show us the ACTUAL code you are using * show us the full traceback, not just the error message * and don't expect us to guess what you are doing Thank you. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
Can't import modules
Top