Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #30565 > unrolled thread
| Started by | Peter Farrell <peterfarrell66@gmail.com> |
|---|---|
| First post | 2012-09-30 12:42 -0700 |
| Last post | 2012-09-30 23:10 -0700 |
| Articles | 19 — 8 participants |
Back to article view | Back to comp.lang.python
Can't import modules Peter Farrell <peterfarrell66@gmail.com> - 2012-09-30 12:42 -0700
Re: Can't import modules Benjamin Kaplan <benjamin.kaplan@case.edu> - 2012-09-30 13:15 -0700
Re: Can't import modules Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-30 20:21 +0000
Re: Can't import modules Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-30 20:21 +0000
Re: Can't import modules Hans Mulder <hansmu@xs4all.nl> - 2012-09-30 22:21 +0200
Re: Can't import modules Peter Farrell <peterfarrell66@gmail.com> - 2012-09-30 17:35 -0700
Re: Can't import modules Dave Angel <d@davea.name> - 2012-09-30 21:16 -0400
Re: Can't import modules Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-10-01 01:25 +0000
Re: Can't import modules Peter Farrell <peterfarrell66@gmail.com> - 2012-09-30 18:35 -0700
Re: Can't import modules Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-10-01 02:15 +0000
Re: Can't import modules Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-10-01 02:15 +0000
Re: Can't import modules Dwight Hutto <dwightdhutto@gmail.com> - 2012-09-30 22:39 -0400
Re: Can't import modules Dwight Hutto <dwightdhutto@gmail.com> - 2012-09-30 22:48 -0400
Re: Can't import modules Dwight Hutto <dwightdhutto@gmail.com> - 2012-09-30 23:12 -0400
Re: Can't import modules Dave Angel <d@davea.name> - 2012-09-30 23:18 -0400
Re: Can't import modules Peter Farrell <peterfarrell66@gmail.com> - 2012-09-30 21:44 -0700
Re: Can't import modules Peter Farrell <peterfarrell66@gmail.com> - 2012-09-30 21:44 -0700
Re: Can't import modules Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-10-01 09:36 +0100
Re: Can't import modules cjgohlke@gmail.com - 2012-09-30 23:10 -0700
| From | Peter Farrell <peterfarrell66@gmail.com> |
|---|---|
| Date | 2012-09-30 12:42 -0700 |
| Subject | Can't import modules |
| Message-ID | <36813ff7-68b9-44eb-9b25-7c13ae739566@googlegroups.com> |
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
[toc] | [next] | [standalone]
| From | Benjamin Kaplan <benjamin.kaplan@case.edu> |
|---|---|
| Date | 2012-09-30 13:15 -0700 |
| Message-ID | <mailman.1682.1349036310.27098.python-list@python.org> |
| In reply to | #30565 |
On Sun, Sep 30, 2012 at 12:42 PM, Peter Farrell <peterfarrell66@gmail.com> 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
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2012-09-30 20:21 +0000 |
| Message-ID | <5068a9cb$0$29982$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #30565 |
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
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2012-09-30 20:21 +0000 |
| Message-ID | <5068a9ac$0$29981$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #30565 |
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
[toc] | [prev] | [next] | [standalone]
| From | Hans Mulder <hansmu@xs4all.nl> |
|---|---|
| Date | 2012-09-30 22:21 +0200 |
| Message-ID | <5068a9e0$0$6915$e4fe514c@news2.news.xs4all.nl> |
| In reply to | #30565 |
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
[toc] | [prev] | [next] | [standalone]
| From | Peter Farrell <peterfarrell66@gmail.com> |
|---|---|
| Date | 2012-09-30 17:35 -0700 |
| Message-ID | <2e36e097-a43f-43b4-98a6-8da999c39c21@googlegroups.com> |
| In reply to | #30569 |
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
[toc] | [prev] | [next] | [standalone]
| From | Dave Angel <d@davea.name> |
|---|---|
| Date | 2012-09-30 21:16 -0400 |
| Message-ID | <mailman.1688.1349054275.27098.python-list@python.org> |
| In reply to | #30576 |
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
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2012-10-01 01:25 +0000 |
| Message-ID | <5068f109$0$29997$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #30576 |
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
[toc] | [prev] | [next] | [standalone]
| From | Peter Farrell <peterfarrell66@gmail.com> |
|---|---|
| Date | 2012-09-30 18:35 -0700 |
| Message-ID | <de7f0448-d56d-4353-af72-a25f3f802f7f@googlegroups.com> |
| In reply to | #30582 |
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
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2012-10-01 02:15 +0000 |
| Message-ID | <5068fcab$0$29997$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #30583 |
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
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2012-10-01 02:15 +0000 |
| Message-ID | <5068fcab$0$1726$c3e8da3$76491128@news.astraweb.com> |
| In reply to | #30583 |
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
[toc] | [prev] | [next] | [standalone]
| From | Dwight Hutto <dwightdhutto@gmail.com> |
|---|---|
| Date | 2012-09-30 22:39 -0400 |
| Message-ID | <mailman.1691.1349059196.27098.python-list@python.org> |
| In reply to | #30585 |
On Sun, Sep 30, 2012 at 10:15 PM, Steven D'Aprano <steve+comp.lang.python@pearwood.info> 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
[toc] | [prev] | [next] | [standalone]
| From | Dwight Hutto <dwightdhutto@gmail.com> |
|---|---|
| Date | 2012-09-30 22:48 -0400 |
| Message-ID | <mailman.1692.1349059685.27098.python-list@python.org> |
| In reply to | #30585 |
Plus from What's New From Python 3", which are things you should be able to change comes: http://docs.python.org/release/3.0.1/whatsnew/3.0.html Change the module yourself. -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com
[toc] | [prev] | [next] | [standalone]
| From | Dwight Hutto <dwightdhutto@gmail.com> |
|---|---|
| Date | 2012-09-30 23:12 -0400 |
| Message-ID | <mailman.1693.1349061168.27098.python-list@python.org> |
| In reply to | #30585 |
On Sun, Sep 30, 2012 at 10:48 PM, Dwight Hutto <dwightdhutto@gmail.com> wrote: > Plus from What's New From Python 3", which are things you should be > able to change comes: > > http://docs.python.org/release/3.0.1/whatsnew/3.0.html > > Change the module yourself. > > And, of course: http://docs.python.org/library/2to3.html -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com
[toc] | [prev] | [next] | [standalone]
| From | Dave Angel <d@davea.name> |
|---|---|
| Date | 2012-09-30 23:18 -0400 |
| Message-ID | <mailman.1694.1349061544.27098.python-list@python.org> |
| In reply to | #30583 |
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
[toc] | [prev] | [next] | [standalone]
| From | Peter Farrell <peterfarrell66@gmail.com> |
|---|---|
| Date | 2012-09-30 21:44 -0700 |
| Message-ID | <6edd4676-e4e8-4f1a-b82b-4699ed470792@googlegroups.com> |
| In reply to | #30590 |
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
[toc] | [prev] | [next] | [standalone]
| From | Peter Farrell <peterfarrell66@gmail.com> |
|---|---|
| Date | 2012-09-30 21:44 -0700 |
| Message-ID | <mailman.1698.1349066673.27098.python-list@python.org> |
| In reply to | #30590 |
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
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2012-10-01 09:36 +0100 |
| Message-ID | <mailman.1702.1349080468.27098.python-list@python.org> |
| In reply to | #30582 |
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.
[toc] | [prev] | [next] | [standalone]
| From | cjgohlke@gmail.com |
|---|---|
| Date | 2012-09-30 23:10 -0700 |
| Message-ID | <550089ae-edde-447d-a977-712bc4125acb@googlegroups.com> |
| In reply to | #30576 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web