I have a question about the same module that has been distributed on several directories.
Assume that I have these two files and directories:
~ / lib / python xxx __init__.py Usage____it module_module2.py / Graphics / python xxx __init__.py misc __init__.py module3 Py module4.py
Then in my Python module, I did this:
import sys pythonlibpath = '~ / lib / python' If Python Lippeath Not in Sys.path: sys.path.append (pythonlibpath) import xxx.util.module1
that works.
Now, the problem is that I need xxx. Misc.module3, so I did this:
import sys graphicslibpath = '~ / graphics / python' If the graphics libpath is not in sys.path: sys.path.append (graphicslibpath) import xxx .misc. Module 3
but I get this error:
importError: no module named Misc.module3
It seems that it somehow still remembers that ~ / lib / python had an xxx package and again tries to find misc.module3.
How do I get this issue?
You can do a trick without any excessive invoicing. In another package package Python requires that the package All modules are under a single subdirectory. To see how to handle os.path
, see os
source.
Comments
Post a Comment