Packages and PyKyra

Robert Clayton rjc at tampabay.rr.com
Thu Sep 25 13:24:56 EDT 2003


Thank you!

There are no PyKyra .py, .pyc, .pyd files.

There is a release PyKyra.dll and a source directory contains a __init__.py
file.

Trying to use the PyKyra.dll returns:

"ImportError: dynamic module does not define init function (initPyKyra)"

Therefore I was attempting to define the location of the Package (directory
structure).
There is little information about creating path references for Packages in
Windows.
Some material suggest various registry entrys others suggest a environment
variable.

I have attempted the three suggestions I found:

1)  A System Environment Variable "PYTHONPATH" with the directory string.
2)  Addition of the directory to the existing Registry Key String
"HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.2\PythonPath"
3)  Creation of a new Registry Key
HKEY_LOCAL_MACHINE\SOFTWARE\Python\PYTHONPATH with the accompanying
directory,

None of these seem to work.  The error "ImportError:  No module named
xxxxxxxx" appears to mean that nothing is treated as a package.

"Alex Martelli" <aleax at aleax.it> wrote in message
news:6wCcb.164799$R32.5291608 at news2.tin.it...
> Robert Clayton wrote:
>
> > In the PyKyra example programs what does the statement:
> >
> > "from PyKyra import *"
> >
> > I now assume that this represents a Package hierarchy and not the file
> > "PyKyra.py" as there is none but for Windows 2000 I am unable to
determine
> > whereor how  the path is represented (registry, environment, etc.).  Any
> > suggestions?
>
> I have no idea about what PyKyra is, but:
>
> [a]
> You can find out what the path is, at any time, by the two statements:
>
> import sys
> print sys.path
>
> [b]
> If you're right in stating there is no PyKyra.py file, then the
> import may be coming from:
>     [b1] a PyKyra.pyc or .pyo bytecode file
>     [b2] a PyKyra.pyd or .dll C-coded extension module
>     [b3] the __init__.py file in a PyKyra directory on the path
>
> The only case involving "packages" is [b3] -- that's what a
> package _IS_... a directory with an __init__.py file.
>
>
> In any case, the "from PyKyra import *" statement gets the
> contents listed in the __all__ entry in module PyKyra, or, if
> no such entry, then all entries in module PyKyra whose names
> do not start with a single underscore character _ .
>
> The usage of "from whatever import *" is generally unadvisable
> except perhaps in those rare cases in which module 'whatever'
> has been carefully designed to support this.  Personally, I've
> lost the habit of "import *" just about entirely -- even for
> carefully designed modules such as Tkinter and Numeric, I do
> "import Tkinter as Tk" or "import Numeric as N" and then access
> their entries explicitly as Tk.Tk, N.array, etc, etc.  I find,
> personally, that this makes my programs more maintainable.
>
>
> Alex
>
>






More information about the Python-list mailing list