我似乎遇到了障礙,根本無法弄清楚這一點,誰能幫我弄清楚爲什麼我無法導入java模塊?import java ImportError:沒有名爲java的模塊
錯誤:
Traceback (most recent call last):
File "./datasource_config.py", line 3, in ?
import java
ImportError: No module named java
的java:
13:30:05 # which java
/usr/bin/java
腳本的開始
#!/usr/bin/python
import sys
import java
from java.util import Properties
from java.io import FileInputStream
from org.python.modules import time
lineSep = java.lang.System.getProperty('line.separator')
def datasource(cluster,user,password,url,env,jdbc_driver,timeOut,maxConn,minConn,reapTime,unusdTimeout,agedTimeout):
#Declare global variables
global AdminConfig
global AdminControl
有人可以幫助我確定這是什麼意思?
13:45:07 # ./jython -v /opt/websphere/datasource_config.py
*sys-package-mgr*: can't create package cache dir, '/usr/lib/jython-25/cachedir/packages'
import: 'exceptions' as org.python.core.exceptions in builtin modules
import: 'site' as /usr/lib/jython-25/Lib/site.py
import: 'sys' as sys in builtin modules
import: 'os' as /usr/lib/jython-25/Lib/os.py
import: 'errno' as org.python.modules.errno in builtin modules
import: 'posix' as org.python.modules.posix.PosixModule in builtin modules
import: 'posixpath' as /usr/lib/jython-25/Lib/posixpath.py
import: 'stat' as /usr/lib/jython-25/Lib/stat.py
import: 'Properties' as java class
import: 'FileInputStream' as java class
Traceback (most recent call last):
File "/opt/websphere/datasource_config.py", line 5, in <module>
from org.python.modules import time
ImportError: cannot import name time
您可能安裝了'java',但這不像可以在python中導入的名爲'java'的python模塊。你真的想做什麼? – doctorlove
您正嘗試從python腳本中調用java。所以這個問題沒有意義 –
導入名爲java的python模塊 – Blogger11