ImportError:ubuntu 14.04上没有名为resources的模块

时间:2017-02-02 06:11:30

标签: python python-2.7 machine-learning scikit-learn ubuntu-14.04

我得到了这个奇怪的错误,没有找到命名资源的模块。我在SO上阅读了很多答案,他们在Windows上遇到了类似的问题。所以,我无法弄清楚为什么在我的机器上发生这个问题(ubuntu 14.04)。我尝试在其他人的ubuntu 14.04机器上运行以下代码,它运行正常。任何人都可以帮我解决这个问题。

代码:

import pickle
import numpy as np
from sklearn.neural_network import MLPClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
from sklearn.externals import joblib
from sklearn2pmml import PMMLPipeline
from sklearn2pmml import sklearn2pmml

# filename = 'TrainLSDataset.csv'
f = open("TrainLSDataset.csv")
data = np.loadtxt(f,delimiter = ',')

x = data[:, 1:]
y = data[:, 0]
X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.3)

clf = MLPClassifier(solver='lbfgs', alpha=1e-5,
                    hidden_layer_sizes=(5), random_state=1, max_iter=100)

clf.fit(X_train, y_train)
pipeline = PMMLPipeline([
  ('clf', clf)
])

sklearn2pmml(pipeline, "pipeline.pmml",debug = True)

错误:

('python: ', '2.7.9')
('sklearn: ', '0.18.1')
('sklearn.externals.joblib:', '0.10.3')
('pandas: ', u'0.19.1')
('sklearn_pandas: ', '1.3.0')
('sklearn2pmml: ', '0.16.0')
Traceback (most recent call last):
  File "LeadScore.py", line 49, in <module>
    sklearn2pmml(pipeline, "pipeline.pmml",debug = True)
  File "/home/naresh/Desktop/Work/Spark-CassandraWork/MachineLearning/sklearn2pmml.py", line 120, in sklearn2pmml
    cmd = ["java", "-cp", os.pathsep.join(_package_classpath() + user_classpath), "org.jpmml.sklearn.Main"]
  File "/home/naresh/Desktop/Work/Spark-CassandraWork/MachineLearning/sklearn2pmml.py", line 75, in _package_classpath
    resources = pkg_resources.resource_listdir("sklearn2pmml.resources", "")
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1220, in resource_listdir
    return get_provider(package_or_requirement).resource_listdir(
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 430, in get_provider
    __import__(moduleOrReq)
ImportError: No module named resources

0 个答案:

没有答案