Can't import modules

Discussion in 'Python' started by Peter Farrell, Sep 30, 2012.

  1. Hello!

    I'm still new to Python, so here's another easy one. After I save something I've done as a .py file, how do I import it into something else I work on? Every time I try to import something other than turtle or math, I get this error message:

    'module' object is not callable

    What am I doing wrong?

    Thanks!

    Peter Farrell
    San Mateo, CA
     
    Peter Farrell, Sep 30, 2012
    #1
    1. Advertising

  2. On Sun, Sep 30, 2012 at 12:42 PM, Peter Farrell
    <> wrote:
    > Hello!
    >
    > I'm still new to Python, so here's another easy one. After I save something I've done as a .py file, how do I import it into something else I work on? Every time I try to import something other than turtle or math, I get this error message:
    >
    > 'module' object is not callable
    >
    > What am I doing wrong?
    >
    > Thanks!
    >
    > Peter Farrell
    > San Mateo, CA
    > --


    Well, you haven't told us what you're doing, so it's hard to say what
    you're doing wrong. So I'm going to make a few guesses.

    1. Your first (and possibly only other) language was Java.
    2. You're making a class (let's say Foo) and putting it in a file of
    the same name (Foo.py)
    3. You're doing "import Foo" and then calling "Foo()" trying to
    instantiate the class.

    Python doesn't have that "one class per file, and the file must have
    the same name as the class" rule as Java. The file defines a module,
    which is an object and can have any number of objects (including
    classes, because those are objects too) in it.

    $ cat foo.py
    class Foo(object):
    pass

    def add2(y) :
    return y + 2
    bkaplan:~ bkaplan$ python
    Python 2.7.3 (default, Apr 23 2012, 10:06:17)
    [GCC 4.2.1 Compatible Apple Clang 3.1 (tags/Apple/clang-318.0.58)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import foo
    >>> dir(foo)

    ['Foo', '__builtins__', '__doc__', '__file__', '__name__',
    '__package__', 'add2', 'x']
    >>> foo()

    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    TypeError: 'module' object is not callable
    >>> foo.Foo()

    <foo.Foo object at 0x100ad9d10>
    >>> foo.add2(5)

    7
     
    Benjamin Kaplan, Sep 30, 2012
    #2
    1. Advertising

  3. On Sun, 30 Sep 2012 12:42:37 -0700, Peter Farrell wrote:

    > Hello!
    >
    > I'm still new to Python, so here's another easy one. After I save
    > something I've done as a .py file, how do I import it into something
    > else I work on? Every time I try to import something other than turtle
    > or math, I get this error message:
    >
    > 'module' object is not callable
    >
    > What am I doing wrong?



    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.


    --
    Steven
     
    Steven D'Aprano, Sep 30, 2012
    #3
  4. On Sun, 30 Sep 2012 12:42:37 -0700, Peter Farrell wrote:

    > Hello!
    >
    > I'm still new to Python, so here's another easy one. After I save
    > something I've done as a .py file, how do I import it into something
    > else I work on? Every time I try to import something other than turtle
    > or math, I get this error message:
    >
    > 'module' object is not callable
    >
    > What am I doing wrong?



    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.


    --
    Steven
     
    Steven D'Aprano, Sep 30, 2012
    #4
  5. Peter Farrell

    Hans Mulder Guest

    On 30/09/12 21:42:37, Peter Farrell wrote:
    > I'm still new to Python, so here's another easy one. After I save something
    > I've done as a .py file, how do I import it into something else I work on?
    > Every time I try to import something other than turtle or math, I get this error message:
    >
    > 'module' object is not callable
    >
    > What am I doing wrong?


    For starters, you're not showing us any code.

    The error message suggests that you have successfully imported
    a module, and you then try to use the module as if it were a
    callable. That won't work: modules are not callable.

    My crystal ball says that you may have been a Java programmer
    in an earlier life. In Java, a file must define exactly one
    class, and the class must have the same name as the file.

    Python is not Java. In Python, a file may define one class,
    or twenty, or none at all. To avoid confusion, do not give
    any of your classes the same name as any of your files.


    Hope this helps,

    -- HansM
     
    Hans Mulder, Sep 30, 2012
    #5
  6. Thanks for trying to help, everybody. Sorry I didn't post the whole error message. Now my problem is I just installed VPython and I'm trying to run the very first example, bounce.py which I located. I opened it and ran it in Idle. I got this message:

    Traceback (most recent call last):
    File "C:\Python32\Lib\site-packages\visual\examples\bounce.py", line 1, in <module>
    from visual import *
    File "C:\Python32\lib\site-packages\visual\__init__.py", line 1, in <module>
    from .visual_all import *
    File "C:\Python32\lib\site-packages\visual\visual_all.py", line 1, in <module>
    from vis import version
    File "C:\Python32\lib\site-packages\vis\__init__.py", line 3, in <module>
    from .cvisual import (vector, dot, mag, mag2, norm, cross, rotate,
    SystemError: initialization of cvisual raised unreported exception

    I'm not a programmer, just a math teacher/tutor who's trying to teach my students to understand math through using something real like Python. I'll keep you posted on my progress.

    Thank you in advance for your help!

    Peter

    On Sunday, September 30, 2012 1:22:31 PM UTC-7, Hans Mulder wrote:
    > On 30/09/12 21:42:37, Peter Farrell wrote:
    >
    > > I'm still new to Python, so here's another easy one. After I save something

    >
    > > I've done as a .py file, how do I import it into something else I work on?

    >
    > > Every time I try to import something other than turtle or math, I get this error message:

    >
    > >

    >
    > > 'module' object is not callable

    >
    > >

    >
    > > What am I doing wrong?

    >
    >
    >
    > For starters, you're not showing us any code.
    >
    >
    >
    > The error message suggests that you have successfully imported
    >
    > a module, and you then try to use the module as if it were a
    >
    > callable. That won't work: modules are not callable.
    >
    >
    >
    > My crystal ball says that you may have been a Java programmer
    >
    > in an earlier life. In Java, a file must define exactly one
    >
    > class, and the class must have the same name as the file.
    >
    >
    >
    > Python is not Java. In Python, a file may define one class,
    >
    > or twenty, or none at all. To avoid confusion, do not give
    >
    > any of your classes the same name as any of your files.
    >
    >
    >
    >
    >
    > Hope this helps,
    >
    >
    >
    > -- HansM
     
    Peter Farrell, Oct 1, 2012
    #6
  7. Peter Farrell

    Dave Angel Guest

    On 09/30/2012 08:35 PM, Peter Farrell wrote:

    You top-posted, which means there's no context; the message is now out
    of order. Please put your responses after the parts you're quoting, or
    don't bother quoting.

    > Thanks for trying to help, everybody. Sorry I didn't post the whole error message. Now my problem is I just installed VPython and I'm trying to run the very first example, bounce.py which I located. I opened it and ran it in Idle. I got this message:
    >
    > Traceback (most recent call last):
    > File "C:\Python32\Lib\site-packages\visual\examples\bounce.py", line 1, in <module>
    > from visual import *
    > File "C:\Python32\lib\site-packages\visual\__init__.py", line 1, in <module>
    > from .visual_all import *
    > File "C:\Python32\lib\site-packages\visual\visual_all.py", line 1, in <module>
    > from vis import version
    > File "C:\Python32\lib\site-packages\vis\__init__.py", line 3, in <module>
    > from .cvisual import (vector, dot, mag, mag2, norm, cross, rotate,
    > SystemError: initialization of cvisual raised unreported exception


    That's a different error message than you reported at first. If you
    can't even run an example supplied with the system, you'd better post a
    question on the vpython forum (I presume it's available from
    http://vpython.wikidot.com/system:join) Presumably the install program
    is broken. Or maybe you just can't run visual from IDLE. Try running
    from the terminal prompt.

    I'm amazed that it uses the form: from visual_all import *
    That's considered bad form. Still, it's probably not the problem. What
    happens if you write a two line program:
    import visual_all
    print("Import succeeded")


    > I'm not a programmer, just a math teacher/tutor who's trying to teach my students to understand math through using something real like Python. I'll keep you posted on my progress.
    >
    > Thank you in advance for your help!
    >
    >


    --

    DaveA
     
    Dave Angel, Oct 1, 2012
    #7
  8. On Sun, 30 Sep 2012 17:35:02 -0700, Peter Farrell wrote:

    > Thanks for trying to help, everybody. Sorry I didn't post the whole
    > error message. Now my problem is I just installed VPython and I'm trying
    > to run the very first example, bounce.py which I located. I opened it
    > and ran it in Idle. I got this message:


    In general, any time you get unexpected or unusual errors in IDLE, you
    should try running the same code without IDLE, just at the regular Python
    prompt. Like all "Integrated Development Environments", IDLE sometimes
    messes about with things in the background that very occasionally
    interferes with the normal running of certain Python code, so it is
    always worth taken IDLE out of the picture whenever there is a mysterious
    failure.

    In Windows, I *think* that if you run "python" (or perhaps "python32")
    from the Start Menu, it will open an interactive prompt similar to IDLE.
    Once the Python interactive interpreter has launched, just enter:

    from visual import *

    and see if it works. If it fails, try:

    import visual


    My wild guess is that VPython (whatever that is!) only works under Python
    2, not Python 3, but I could be wrong.

    Other than that, my advice is to check with a dedicated VPython mailing
    list. Oh, and if you do find the solution, please consider reporting what
    the solution is back here, for the benefit of the next person who runs
    into this issue.



    --
    Steven
     
    Steven D'Aprano, Oct 1, 2012
    #8
  9. On Sunday, September 30, 2012 6:25:29 PM UTC-7, Steven D'Aprano wrote:
    > On Sun, 30 Sep 2012 17:35:02 -0700, Peter Farrell wrote:
    >
    >
    >
    > > Thanks for trying to help, everybody. Sorry I didn't post the whole

    >
    > > error message. Now my problem is I just installed VPython and I'm trying

    >
    > > to run the very first example, bounce.py which I located. I opened it

    >
    > > and ran it in Idle. I got this message:

    >
    >
    >
    > In general, any time you get unexpected or unusual errors in IDLE, you
    >
    > should try running the same code without IDLE, just at the regular Python
    >
    > prompt. Like all "Integrated Development Environments", IDLE sometimes
    >
    > messes about with things in the background that very occasionally
    >
    > interferes with the normal running of certain Python code, so it is
    >
    > always worth taken IDLE out of the picture whenever there is a mysterious
    >
    > failure.
    >
    >
    >
    > In Windows, I *think* that if you run "python" (or perhaps "python32")
    >
    > from the Start Menu, it will open an interactive prompt similar to IDLE.
    >
    > Once the Python interactive interpreter has launched, just enter:
    >
    >
    >
    > from visual import *
    >
    >
    >
    > and see if it works. If it fails, try:
    >
    >
    >
    > import visual
    >
    >
    >
    >
    >
    > My wild guess is that VPython (whatever that is!) only works under Python
    >
    > 2, not Python 3, but I could be wrong.
    >
    >
    >
    > Other than that, my advice is to check with a dedicated VPython mailing
    >
    > list. Oh, and if you do find the solution, please consider reporting what
    >
    > the solution is back here, for the benefit of the next person who runs
    >
    > into this issue.
    >
    >
    >
    >
    >
    >
    >
    > --
    >
    > Steven


    Thanks again for the help. I entered the import statements you suggested into the Python Shell and they gave me the same error message. (Neither did visual_all, but of course the print statement worked.)

    Since I use Python 3.2.3 I've had trouble with programs and modules designed for Python 2 and many programs don't work on my 64-bit system.

    I was hoping it was a common error that newbies encounter.

    Thanks again, Python fans. I'll keep you posted on my progress!

    Peter
     
    Peter Farrell, Oct 1, 2012
    #9
  10. On Sun, 30 Sep 2012 18:35:50 -0700, Peter Farrell wrote:

    > Since I use Python 3.2.3 I've had trouble with programs and modules
    > designed for Python 2 and many programs don't work on my 64-bit system.


    While Python tries very hard to be backward compatible, the transition
    from the 2.x series to the 3.x series was intentionally allowed to break
    backward compatibility in certain areas.

    If VPython only supports 2.x, you should ask the vendors to support at
    least 3.3 or better, preferably the full 3.x series. In the meantime, you
    may have to stick to the 2.x series.


    > I was hoping it was a common error that newbies encounter.


    Trying to run Python 2.x code in 3.x? Yes, that's common. Trying to run
    VPython? Not so much.

    Good luck!


    --
    Steven
     
    Steven D'Aprano, Oct 1, 2012
    #10
  11. On Sun, 30 Sep 2012 18:35:50 -0700, Peter Farrell wrote:

    > Since I use Python 3.2.3 I've had trouble with programs and modules
    > designed for Python 2 and many programs don't work on my 64-bit system.


    While Python tries very hard to be backward compatible, the transition
    from the 2.x series to the 3.x series was intentionally allowed to break
    backward compatibility in certain areas.

    If VPython only supports 2.x, you should ask the vendors to support at
    least 3.3 or better, preferably the full 3.x series. In the meantime, you
    may have to stick to the 2.x series.


    > I was hoping it was a common error that newbies encounter.


    Trying to run Python 2.x code in 3.x? Yes, that's common. Trying to run
    VPython? Not so much.

    Good luck!


    --
    Steven
     
    Steven D'Aprano, Oct 1, 2012
    #11
  12. Peter Farrell

    Dwight Hutto Guest

    On Sun, Sep 30, 2012 at 10:15 PM, Steven D'Aprano
    <> wrote:
    > On Sun, 30 Sep 2012 18:35:50 -0700, Peter Farrell wrote:
    >
    >> Since I use Python 3.2.3 I've had trouble with programs and modules
    >> designed for Python 2 and many programs don't work on my 64-bit system.

    >
    > While Python tries very hard to be backward compatible, the transition
    > from the 2.x series to the 3.x series was intentionally allowed to break
    > backward compatibility in certain areas.
    >
    > If VPython only supports 2.x,


    Naw , that's your job, plus maybe looking through the python code for
    Vpython, and adding a little "from __future__ import *"
    you should ask the vendors to support at
    > least 3.3 or better, preferably the full 3.x series. In the meantime, you
    > may have to stick to the 2.x series.
    >
    >
    >> I was hoping it was a common error that newbies encounter.

    >
    > Trying to run Python 2.x code in 3.x? Yes, that's common. Trying to run
    > VPython? Not so much.
    >
    > Good luck!
    >
    >
    > --
    > Steven
    > --
    > http://mail.python.org/mailman/listinfo/python-list




    --
    Best Regards,
    David Hutto
    CEO: http://www.hitwebdevelopment.com
     
    Dwight Hutto, Oct 1, 2012
    #12
  13. Peter Farrell

    Dwight Hutto Guest

    Dwight Hutto, Oct 1, 2012
    #13
  14. Peter Farrell

    Dwight Hutto Guest

    Dwight Hutto, Oct 1, 2012
    #14
  15. Peter Farrell

    Dave Angel Guest

    On 09/30/2012 09:35 PM, Peter Farrell wrote:
    > On Sunday, September 30, 2012 6:25:29 PM UTC-7, Steven D'Aprano wrote:
    >> On Sun, 30 Sep 2012 17:35:02 -0700, Peter Farrell wrote:
    >>
    >>
    >>
    >>> Thanks for trying to help, everybody. Sorry I didn't post the whole
    >>> error message. Now my problem is I just installed VPython and I'm trying
    >>> to run the very first example, bounce.py which I located. I opened it
    >>> and ran it in Idle. I got this message:

    >>
    >>
    >> In general, any time you get unexpected or unusual errors in IDLE, you
    >> should try running the same code without IDLE, just at the regular Python
    >> prompt.
    >> <SNIP>

    > Thanks again for the help. I entered the import statements you suggested into the Python Shell and they gave me the same error message. (Neither did visual_all, but of course the print statement worked.)


    Don't run it in the Python Shell, and don't use IDLE at all. Run your
    test either at the cmd window, or from plain Python's interactive
    interpreter, or maybe from VIDLE.

    >From the official download page:

    http://www.vpython.org/contents/download_windows.html


    """How to run VPython

    *

    Start the program editor with the "VIDLE for Python" shortcut on the
    desktop
    or on the Start menu.

    *

    Open an example program -- for example, bounce2.py.

    *

    Press F5 to run (or use the Run menu).

    """


    > Since I use Python 3.2.3 I've had trouble with programs and modules designed for Python 2 and many programs don't work on my 64-bit system.
    >
    > I was hoping it was a common error that newbies encounter.
    >
    > Thanks again, Python fans. I'll keep you posted on my progress!

    VPython has separate versions for Python 2.7 and 3.2 Hopefully you
    downloaded the 3.2 version, since you're running it in c:\python32

    Also, these are for the 32bit version of CPython. So double-check which
    one you've got installed.



    --

    DaveA
     
    Dave Angel, Oct 1, 2012
    #15
  16. On Sunday, September 30, 2012 8:19:28 PM UTC-7, Dave Angel wrote:
    > On 09/30/2012 09:35 PM, Peter Farrell wrote:
    >
    > > On Sunday, September 30, 2012 6:25:29 PM UTC-7, Steven D'Aprano wrote:

    >
    > >> On Sun, 30 Sep 2012 17:35:02 -0700, Peter Farrell wrote:

    >
    > >>

    >
    > >>

    >
    > >>

    >
    > >>> Thanks for trying to help, everybody. Sorry I didn't post the whole

    >
    > >>> error message. Now my problem is I just installed VPython and I'm trying

    >
    > >>> to run the very first example, bounce.py which I located. I opened it

    >
    > >>> and ran it in Idle. I got this message:

    >
    > >>

    >
    > >>

    >
    > >> In general, any time you get unexpected or unusual errors in IDLE, you

    >
    > >> should try running the same code without IDLE, just at the regular Python

    >
    > >> prompt.

    >
    > >> <SNIP>

    >
    > > Thanks again for the help. I entered the import statements you suggested into the Python Shell and they gave me the same error message. (Neither did visual_all, but of course the print statement worked.)

    >
    >
    >
    > Don't run it in the Python Shell, and don't use IDLE at all. Run your
    >
    > test either at the cmd window, or from plain Python's interactive
    >
    > interpreter, or maybe from VIDLE.
    >
    >
    >
    > >From the official download page:

    >
    > http://www.vpython.org/contents/download_windows.html
    >
    >
    >
    >
    >
    > """How to run VPython
    >
    >
    >
    > *
    >
    >
    >
    > Start the program editor with the "VIDLE for Python" shortcut on the
    >
    > desktop
    >
    > or on the Start menu.
    >
    >
    >
    > *
    >
    >
    >
    > Open an example program -- for example, bounce2.py.
    >
    >
    >
    > *
    >
    >
    >
    > Press F5 to run (or use the Run menu).
    >
    >
    >
    > """
    >
    >
    >
    >
    >
    > > Since I use Python 3.2.3 I've had trouble with programs and modules designed for Python 2 and many programs don't work on my 64-bit system.

    >
    > >

    >
    > > I was hoping it was a common error that newbies encounter.

    >
    > >

    >
    > > Thanks again, Python fans. I'll keep you posted on my progress!

    >
    > VPython has separate versions for Python 2.7 and 3.2 Hopefully you
    >
    > downloaded the 3.2 version, since you're running it in c:\python32
    >
    >
    >
    > Also, these are for the 32bit version of CPython. So double-check which
    >
    > one you've got installed.
    >
    >
    >
    >
    >
    >
    >
    > --
    >
    >
    >
    > DaveA

    Yes, I downloaded the 3.2 version but on 64-bit. None of the 32-bit Python programs I've installed have worked.

    VPython didn't install a VIDLE icon on my desktop. An earlier version did, but then it said it couldn't find the .exe file to work!

    I've sent a message to the VPython groups. I'm looking forward to using this program, when it finally works!

    Thanks again,

    Peter
     
    Peter Farrell, Oct 1, 2012
    #16
  17. On Sunday, September 30, 2012 8:19:28 PM UTC-7, Dave Angel wrote:
    > On 09/30/2012 09:35 PM, Peter Farrell wrote:
    >
    > > On Sunday, September 30, 2012 6:25:29 PM UTC-7, Steven D'Aprano wrote:

    >
    > >> On Sun, 30 Sep 2012 17:35:02 -0700, Peter Farrell wrote:

    >
    > >>

    >
    > >>

    >
    > >>

    >
    > >>> Thanks for trying to help, everybody. Sorry I didn't post the whole

    >
    > >>> error message. Now my problem is I just installed VPython and I'm trying

    >
    > >>> to run the very first example, bounce.py which I located. I opened it

    >
    > >>> and ran it in Idle. I got this message:

    >
    > >>

    >
    > >>

    >
    > >> In general, any time you get unexpected or unusual errors in IDLE, you

    >
    > >> should try running the same code without IDLE, just at the regular Python

    >
    > >> prompt.

    >
    > >> <SNIP>

    >
    > > Thanks again for the help. I entered the import statements you suggested into the Python Shell and they gave me the same error message. (Neither did visual_all, but of course the print statement worked.)

    >
    >
    >
    > Don't run it in the Python Shell, and don't use IDLE at all. Run your
    >
    > test either at the cmd window, or from plain Python's interactive
    >
    > interpreter, or maybe from VIDLE.
    >
    >
    >
    > >From the official download page:

    >
    > http://www.vpython.org/contents/download_windows.html
    >
    >
    >
    >
    >
    > """How to run VPython
    >
    >
    >
    > *
    >
    >
    >
    > Start the program editor with the "VIDLE for Python" shortcut on the
    >
    > desktop
    >
    > or on the Start menu.
    >
    >
    >
    > *
    >
    >
    >
    > Open an example program -- for example, bounce2.py.
    >
    >
    >
    > *
    >
    >
    >
    > Press F5 to run (or use the Run menu).
    >
    >
    >
    > """
    >
    >
    >
    >
    >
    > > Since I use Python 3.2.3 I've had trouble with programs and modules designed for Python 2 and many programs don't work on my 64-bit system.

    >
    > >

    >
    > > I was hoping it was a common error that newbies encounter.

    >
    > >

    >
    > > Thanks again, Python fans. I'll keep you posted on my progress!

    >
    > VPython has separate versions for Python 2.7 and 3.2 Hopefully you
    >
    > downloaded the 3.2 version, since you're running it in c:\python32
    >
    >
    >
    > Also, these are for the 32bit version of CPython. So double-check which
    >
    > one you've got installed.
    >
    >
    >
    >
    >
    >
    >
    > --
    >
    >
    >
    > DaveA

    Yes, I downloaded the 3.2 version but on 64-bit. None of the 32-bit Python programs I've installed have worked.

    VPython didn't install a VIDLE icon on my desktop. An earlier version did, but then it said it couldn't find the .exe file to work!

    I've sent a message to the VPython groups. I'm looking forward to using this program, when it finally works!

    Thanks again,

    Peter
     
    Peter Farrell, Oct 1, 2012
    #17
  18. Peter Farrell

    Guest

    On Sunday, September 30, 2012 5:35:02 PM UTC-7, Peter Farrell wrote:
    > Thanks for trying to help, everybody. Sorry I didn't post the whole errormessage. Now my problem is I just installed VPython and I'm trying to run the very first example, bounce.py which I located. I opened it and ran it in Idle. I got this message:
    >
    >
    >
    > Traceback (most recent call last):
    >
    > File "C:\Python32\Lib\site-packages\visual\examples\bounce.py", line 1,in <module>
    >
    > from visual import *
    >
    > File "C:\Python32\lib\site-packages\visual\__init__.py", line 1, in <module>
    >
    > from .visual_all import *
    >
    > File "C:\Python32\lib\site-packages\visual\visual_all.py", line 1, in <module>
    >
    > from vis import version
    >
    > File "C:\Python32\lib\site-packages\vis\__init__.py", line 3, in <module>
    >
    > from .cvisual import (vector, dot, mag, mag2, norm, cross, rotate,
    >
    > SystemError: initialization of cvisual raised unreported exception
    >
    >


    Works for me on win-amd64-3.2.

    Do you have the numpy package installed? The cvisual extension module uses the numpy C API. The SystemError is expected if numpy is not installed.

    Install numpy-MKL-1.6.2.win-amd64-py3.2.‌exe from http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy if you are using VPython-5.74.win-amd64-py3..2.‌exe.

    Christoph

    > I'm not a programmer, just a math teacher/tutor who's trying to teach my students to understand math through using something real like Python. I'll keep you posted on my progress.
    >
    >
    >
    > Thank you in advance for your help!
    >
    >
    >
    > Peter
    >
    >
    >
    > On Sunday, September 30, 2012 1:22:31 PM UTC-7, Hans Mulder wrote:
    >
    > > On 30/09/12 21:42:37, Peter Farrell wrote:

    >
    > >

    >
    > > > I'm still new to Python, so here's another easy one. After I save something

    >
    > >

    >
    > > > I've done as a .py file, how do I import it into something else I work on?

    >
    > >

    >
    > > > Every time I try to import something other than turtle or math, I getthis error message:

    >
    > >

    >
    > > >

    >
    > >

    >
    > > > 'module' object is not callable

    >
    > >

    >
    > > >

    >
    > >

    >
    > > > What am I doing wrong?

    >
    > >

    >
    > >

    >
    > >

    >
    > > For starters, you're not showing us any code.

    >
    > >

    >
    > >

    >
    > >

    >
    > > The error message suggests that you have successfully imported

    >
    > >

    >
    > > a module, and you then try to use the module as if it were a

    >
    > >

    >
    > > callable. That won't work: modules are not callable.

    >
    > >

    >
    > >

    >
    > >

    >
    > > My crystal ball says that you may have been a Java programmer

    >
    > >

    >
    > > in an earlier life. In Java, a file must define exactly one

    >
    > >

    >
    > > class, and the class must have the same name as the file.

    >
    > >

    >
    > >

    >
    > >

    >
    > > Python is not Java. In Python, a file may define one class,

    >
    > >

    >
    > > or twenty, or none at all. To avoid confusion, do not give

    >
    > >

    >
    > > any of your classes the same name as any of your files.

    >
    > >

    >
    > >

    >
    > >

    >
    > >

    >
    > >

    >
    > > Hope this helps,

    >
    > >

    >
    > >

    >
    > >

    >
    > > -- HansM
     
    , Oct 1, 2012
    #18
  19. On 01/10/2012 02:25, Steven D'Aprano wrote:
    > On Sun, 30 Sep 2012 17:35:02 -0700, Peter Farrell wrote:
    >
    >> Thanks for trying to help, everybody. Sorry I didn't post the whole
    >> error message. Now my problem is I just installed VPython and I'm trying
    >> to run the very first example, bounce.py which I located. I opened it
    >> and ran it in Idle. I got this message:

    >
    > In general, any time you get unexpected or unusual errors in IDLE, you


    >
    > In Windows, I *think* that if you run "python" (or perhaps "python32")
    > from the Start Menu, it will open an interactive prompt similar to IDLE.


    Just python. With the arrival of pylauncher
    http://www.python.org/dev/peps/pep-0397/ you can also type py [options].

    --
    Cheers.

    Mark Lawrence.
     
    Mark Lawrence, Oct 1, 2012
    #19
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Remy Cool
    Replies:
    1
    Views:
    445
    Remy Cool
    Aug 27, 2003
  2. Tobiah
    Replies:
    2
    Views:
    323
    Tobiah
    Sep 14, 2003
  3. MackS
    Replies:
    4
    Views:
    350
  4. Ben Weintraub

    Disabling modules using Modules/Setup

    Ben Weintraub, Sep 9, 2006, in forum: Python
    Replies:
    0
    Views:
    362
    Ben Weintraub
    Sep 9, 2006
  5. Stéphane Klein
    Replies:
    0
    Views:
    297
    Stéphane Klein
    Jul 5, 2011
Loading...

Share This Page