Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #63656
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'subject:Windows': 0.02; 'win32': 0.03; 'importerror:': 0.07; 'subject:Error': 0.07; 'sys': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'def': 0.12; '(created': 0.16; '__init__.py': 0.16; 'attribute:': 0.16; 'btw:': 0.16; 'foo():': 0.16; 'foo,': 0.16; 'imported.': 0.16; 'missing?': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'folder': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'module': 0.19; 'trying': 0.19; 'packages.': 0.19; "skip:' 30": 0.19; 'seems': 0.21; 'command': 0.22; 'machine': 0.22; 'import': 0.22; 'header :User-Agent:1': 0.23; 'error': 0.23; 'directory.': 0.24; 'looks': 0.24; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'skip:( 20': 0.30; "i'm": 0.30; "skip:' 10": 0.31; '"",': 0.31; '>>>>': 0.31; 'ok.': 0.31; 'file': 0.32; 'class': 0.32; 'skip:c 30': 0.32; 'stuff': 0.32; 'run': 0.32; 'open': 0.33; '(most': 0.33; 'skip:_ 10': 0.34; 'maybe': 0.34; 'basic': 0.35; "can't": 0.35; 'common': 0.35; 'something': 0.35; 'there': 0.35; 'nov': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'called': 0.40; 'skip:c 50': 0.60; 'new': 0.61; 'simply': 0.61; 'email addr:gmail.com': 0.63; 'name': 0.63; 'therefore,': 0.64; 'more': 0.64; 'prompt': 0.68; 'unusual': 0.74; "'foo'": 0.84; 'number):': 0.84; '2013,': 0.91; 'technique': 0.93 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Ned Batchelder <ned@nedbatchelder.com> |
| Subject | Re: Input Error issues - Windows 7 |
| Date | Fri, 10 Jan 2014 14:48:10 -0500 |
| References | <e49eae5d-0ca8-44e6-a80a-7906b9dad8c0@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | 18.189.30.229 |
| User-Agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 |
| In-Reply-To | <e49eae5d-0ca8-44e6-a80a-7906b9dad8c0@googlegroups.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5298.1389383301.18130.python-list@python.org> (permalink) |
| Lines | 77 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1389383301 news.xs4all.nl 2913 [2001:888:2000:d::a6]:37303 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:63656 |
Show key headers only | View raw
On 1/10/14 2:38 PM, bryan.kardisco@gmail.com wrote: > I'm new to python and am trying to just get some basic stuff up and going. Welcome! > > I have a very basic module called foo > > It's in the following directory on my machine > > C:\workspace\PyFoo\src\foo > In that folder is __init__.py (created automatically) and foo.py > > foo.py looks like this > > class foo(): > def __init__(self, name, number): > self.name = name > self.number = number > def getName(self): > return self.name > def getNumber(self): > return self.number > > > If I open up command prompt and do following it works: > > C:\workspace\PyFoo\src\foo>python > Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:18:40) [MSC v.1600 32 bit (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. >>>> from foo import foo >>>> f = foo(1,2) >>>> f.getName() > 1 >>>> > > > However, if I run this from C:\ I get the following > > C:\>python > Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:18:40) [MSC v.1600 32 bit (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. >>>> from foo import foo > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > ImportError: No module named 'foo' >>>> > > > I thought, well maybe it's a system error > >>>> import sys >>>> print(sys.path) > ['', 'C:\\Python33', 'C:\\Python33\\Lib', 'C:\\Python33\\DLLs', 'C:\\workspace', 'C:\\Windows\\system32\\python33.zip', > 'C:\\Python33\\lib\\site-packages'] >>>> > > C:\>echo %PYTHONPATH% > C:\Python33;C:\Python33\Lib;C:\Python33\DLLs;C:\workspace > > However, that seems OK. > > Is there something I'm missing? > The PYTHONPATH contains the directories that will be searched for modules and packages. Your package is called foo, and is in c:\workspace\PyFoo\src. That directory is not on the Python path, and it isn't the current directory. Therefore, your package can't be found and imported. BTW: writting getters like getName and getNumber is unusual in Python. The much more common technique is to simply use the attribute: f.name -- Ned Batchelder, http://nedbatchelder.com
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Input Error issues - Windows 7 bryan.kardisco@gmail.com - 2014-01-10 11:38 -0800 Re: Input Error issues - Windows 7 Ned Batchelder <ned@nedbatchelder.com> - 2014-01-10 14:48 -0500 Re: Input Error issues - Windows 7 Dave Angel <davea@davea.name> - 2014-01-10 18:20 -0500
csiph-web