Please help before I weep with frustration...this is sending me over the edge...
Our project has upgraded to WebLogic 11g & I have written WLST offline scripts to create a domain, upgrade to an ADF template, set datasoources, JMS, deploy applications, define security etc.
They work correctly & I am now in the process of updating them from my local development environment, to Windows & Linux production environments (for Maven integration, continuous build & test etc).
As such, I am tidying the POC scripts (parameterised the attributes for the domain into properties files, dynamic selection of number of managed servers, clusters etc etc).
& taking common functions out of all the scripts, & putting them in a commonFunctions.py file for reuse...
It is this change I cannot implement, as I am getting the dreaded 'no module named XXXXX' exception when it is executed.
I have read up on;
Python / Jython relative vs absolute paths
from path1.path2.A import function1, function2
I've changed the locations of the scripts so they all run in the same DIR, tried amending the PYTHON path, everything I can think of.
I'm fairly new(ish) to WLST (but not WebLogic) so I'm obviously missing something obvious, but god knows what it is.
Here's my current setup (I've replaced my parameterised values for the actual values for clarity);
- My start scripts runs from U:/scriptHome with;
- commonFunctions.py contains many functions, but one for example is;
from commonFunctions import logger
Try & run the script & get;
ImportError: no module named commonFunctions
- Windows XP
- WeLogic 11g installed
- Extended the domain (for ADF) [Oracle JFR - 18.104.22.168). Hence oracle_common is now installed.
- Running WLST from C:/Oracle/Middleware/oracle_common/common/bin
- Python is preinstalled on my PC in C:/Progra~1/Python (version 2.4)
- Python Path is C:/Progra~1/Python;C:/Oracle/Middleware/oracle_common/common/bin
_ WLST_HOME (setup for my scripts) is C:/Oracle/Middleware/oracle_common/common/bin
Any ideas would be more than gratefully accepted as I'm currently a broken man.
you cannot import the value in this way.
try this option while importing .py file.
and check whether you get similar issue or not.
num = '1'
This should work for you.
Thanks a lot. Your answer pointed me in the right direction.
I tried using the sys.path.append('..') & from ..commonFunctions import etc commands but the WLST version 11g uses is based on Python 2.2.1 which doesn't support that syntax, which you obviously know.
My initial script sets environment variables for the scripts to use, including the script DIR. So as you suggested, I used sys.path.append(os.environ["DOMAIN_SCRIPT_HOME"]), where DOMAIN_SCRIPT_HOME is U:/scriptHome.
Which now works correctly.
Thanks again for your reply.