The problem is that the apache-poi package you probably installed via yum:
is implemented as Java jar files:
rpm -ql apache-poi
will show you those jars are under /usr/share/java/poi
but your jython script is only looking at python library paths for modules. One way to get that "poi.jar" in your script is to replace that "from org.apache.poi.hssf.usermodel import *" line with:
Quote:
import sys
sys.path.append("/usr/share/java/poi/poi.jar")
from org.apache.poi.hssf.usermodel import *
|
I tried that here and it worked with Pycharm IDE. I suspect there's a better way to include jars in Pycharm but I didn't see it in the "edit configuration" tool.
Then to make sure that even the raw script was working I went to where I put my testpoi.py (copy and paste of your script with my couple lines of edits as shown above)
in my pycharm project:
Quote:
cd ~/PycharmProjects/untitled2/
chmod +x testpoi.py
ls -l
-rw-rw-r--. 1 mos mos 6656 May 26 17:36 Book1.xls
-rwxrwxr-x. 1 mos mos 1005 May 26 17:26 testpoi.py*
|
(note Book1.xls is a simple two row spreadsheet I made for my test containing two rows with some numbers in them like this:
1 2 3
4 4 5
)
Then I just ran it is a raw command line script so it's not running from Pycharm:
Quote:
./testpoi.py
Picked up _JAVA_OPTIONS: -Dswing.aatext=true -Dawt.useSystemAAFontSettings=on -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKL ookAndFeel
Book1.xls
org.apache.poi.hssf.usermodel.HSSFWorkbook@5be7ef2 c org.apache.poi.hssf.usermodel.HSSFSheet@580760d7 2
3
0
1.0
2.0
3.0
1
4.0
4.0
5.0
|
So that works too.
PS. another thing to watch for, I was just trying jython support in Fedora 16 and found that because the jython package in Fedora is very
old and behind the current version (Fedora 16 has version 2.2.1 while the latest stable jython is 2.5.2), some things you're accustomed to using
in normal python 2.7 (like the "with open() as file:" context statement (see:
http://effbot.org/pyref/with.htm ) won't work.
Mark