我在Eclipse中結合了java和python代碼,當我想執行包含pandas模塊的python腳本時,我從java class中調用了null
值。否則,如果我不使用熊貓模塊,但只是簡單的Python腳本一切正常。我認爲PyDev
解釋器正確,並且所有python模塊的路徑配置正確,因爲我沒有得到任何導入錯誤,並且當我在代碼中覆蓋鼠標時,我可以獲取模塊信息。在Eclipse中使用python pandas模塊火星
所有模塊位於/usr/local/lib/python2.7/site-packages。
請檢查java class
,python script
和PyDev
配置:
package test4;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
public class test4 {
public static void main(String a[]){
try{
ProcessBuilder pb = new ProcessBuilder("/usr/local/bin/python2.7","solinor_final.py");
Process p = pb.start();
System.out.println("Hello");
String line = null;
StringBuilder sb = new StringBuilder();
BufferedReader in = null;
try {
in = new BufferedReader(new InputStreamReader(p.getInputStream()));
while((line=in.readLine())!=null) {
sb.append(line);
System.out.println(line);
}
} finally {
in.close();
}
System.out.println("value is : "+sb);
}catch(Exception e){System.out.println(e);}
}
}
的Python:
import sys
sys.path.append("/usr/local/bin")
sys.path.append("/usr/bin/")
sys.path.append('/Users/quuppa/Documents/workspace/test4/report1.csv')
import pandas as pd
def main():
import python_class as so
print "Hello inside"
data = pd.read_csv("report1.csv",sep=",",header=None)
data = data.rename(columns={0:'Merchant name',1:'Business ID',2:'Main merchant ID',3:'Report type',4:'Report search date',5:'Report period',\
6:'Outlet name',7:'Address',8:'Number of transactions',9:'Value of transactions',10:'Commission',11:'Chargebacks and adjustments',12:'Settlement value'})
data = data.drop([data.index[0]])
bd = so.Solinor(data)
total_amount = bd.totalAmount()
print total_amount
if __name__ == "__main__":
main()
這些是具有和不包括大熊貓模塊的輸出:
Hello
value is :
Hello
Hello inside
value is : Hello inside
配置圖像:
你有任何建議,這可能是在運行與大熊貓模塊的代碼有問題嗎?
謝謝!
謝謝法比奧!我做了你所說的一切,現在PyDev報告'AttributeError:'模塊'對象沒有屬性'Integral'',作爲'noduy模塊'的一部分'numbers module',當我運行python時非常奇怪。 – Beltrif