Can't import modules
cjgohlke at gmail.com
cjgohlke at gmail.com
Mon Oct 1 02:10:47 EDT 2012
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 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
>
>
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 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
More information about the Python-list
mailing list