Hello,
I just switched from 2.2 to Python 2.3.
I am developing an XML/CGI interface to databases as a python package called
"unitWrappe r" containing several modules which ran fine under v2.2.
Running Python2.3 under windows2000 I get import errors when a module
imports another module of the same package with absolute package-names like
this:
main script:
"unitWrapper.wr apper" :[color=blue]
>
># import error messages and error logging mechanism
>from unitWrapper.err orclasses import *
>[/color]
'import site' failed; use -v for traceback
Traceback (most recent call last):
File "wrapper.py ", line 67, in ?
from unitWrapper.err orclasses import *
ImportError: No module named unitWrapper.err orclasses
The module exists and curiosly the import above works fine when executed
from outside the package directory. But as soon as there is an import
statement in the imported module unitWrapper.err orclasses, trying to import
other modules in an absolute way, I get the same error again.
I checked the sys.path environment and suprisingly I found that the
site-packages directory is not included when scripts are executed from a
subfolder of site-packages:
sys.path when executing unitWrapper.wra pper.py from site-packages directoy:
['C:\\Python23\\ Lib\\site-packages\\unitW rapper',
'C:\\WINNT\\Sys tem32\\python23 .zip', '', 'C:\\Python23\\ DLLs',
'C:\\Python23\\ lib', 'C:\\Python23\\ lib\\plat-win',
'C:\\Python23\\ lib\\lib-tk', 'C:\\Python23']
sys.path when executing unitWrapper.wra pper.py from outside site-packages
directoy:
['C:\\Documents and Settings\\m.doe ring\\Desktop',
'C:\\WINNT\\Sys tem32\\python23 .zip', 'C:\\Documents and
Settings\\m.doe ring\\Desktop', 'C:\\Python23\\ DLLs', 'C:\\Python23\\ lib',
'C:\\Python23\\ lib\\plat-win', 'C:\\Python23\\ lib\\lib-tk', 'C:\\Python23',
'C:\\Python23\\ lib\\site-packages']
Is this intended ? Has there changed anything according to relative /
absolute adressing of modules ?
How should modules import other modules of the same package? Are only
relative package-names allowed?
And how do I adress a "parental" module from a subpackage in a relative way?
Any help greatly appreciated,
Markus Doering
--
Markus Döring
Botanic Garden and Botanical Museum Berlin Dahlem,
Dept. of Biodiversit y Informatics
Königin-Luise-Str. 6-8, D-14191 Berlin
Email: m.doering@bgbm. org
I just switched from 2.2 to Python 2.3.
I am developing an XML/CGI interface to databases as a python package called
"unitWrappe r" containing several modules which ran fine under v2.2.
Running Python2.3 under windows2000 I get import errors when a module
imports another module of the same package with absolute package-names like
this:
main script:
"unitWrapper.wr apper" :[color=blue]
>
># import error messages and error logging mechanism
>from unitWrapper.err orclasses import *
>[/color]
'import site' failed; use -v for traceback
Traceback (most recent call last):
File "wrapper.py ", line 67, in ?
from unitWrapper.err orclasses import *
ImportError: No module named unitWrapper.err orclasses
The module exists and curiosly the import above works fine when executed
from outside the package directory. But as soon as there is an import
statement in the imported module unitWrapper.err orclasses, trying to import
other modules in an absolute way, I get the same error again.
I checked the sys.path environment and suprisingly I found that the
site-packages directory is not included when scripts are executed from a
subfolder of site-packages:
sys.path when executing unitWrapper.wra pper.py from site-packages directoy:
['C:\\Python23\\ Lib\\site-packages\\unitW rapper',
'C:\\WINNT\\Sys tem32\\python23 .zip', '', 'C:\\Python23\\ DLLs',
'C:\\Python23\\ lib', 'C:\\Python23\\ lib\\plat-win',
'C:\\Python23\\ lib\\lib-tk', 'C:\\Python23']
sys.path when executing unitWrapper.wra pper.py from outside site-packages
directoy:
['C:\\Documents and Settings\\m.doe ring\\Desktop',
'C:\\WINNT\\Sys tem32\\python23 .zip', 'C:\\Documents and
Settings\\m.doe ring\\Desktop', 'C:\\Python23\\ DLLs', 'C:\\Python23\\ lib',
'C:\\Python23\\ lib\\plat-win', 'C:\\Python23\\ lib\\lib-tk', 'C:\\Python23',
'C:\\Python23\\ lib\\site-packages']
Is this intended ? Has there changed anything according to relative /
absolute adressing of modules ?
How should modules import other modules of the same package? Are only
relative package-names allowed?
And how do I adress a "parental" module from a subpackage in a relative way?
Any help greatly appreciated,
Markus Doering
--
Markus Döring
Botanic Garden and Botanical Museum Berlin Dahlem,
Dept. of Biodiversit y Informatics
Königin-Luise-Str. 6-8, D-14191 Berlin
Email: m.doering@bgbm. org
Comment