I just installed Python's scikit-neuralnetwork using the procedure mentioned, that is;
pip install scikit-neuralnetwork
Now I can not import SVM. This line;
from sklearn import svm
gives this error;
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "//anaconda/lib/python2.7/site-packages/sklearn/svm/__init__.py", line 13, in <module>
from .classes import SVC, NuSVC, SVR, NuSVR, OneClassSVM, LinearSVC, \
File "//anaconda/lib/python2.7/site-packages/sklearn/svm/classes.py", line 4, in <module>
from .base import _fit_liblinear, BaseSVC, BaseLibSVM
File "//anaconda/lib/python2.7/site-packages/sklearn/svm/base.py", line 12, in <module>
from ..multiclass import _ovr_decision_function
File "//anaconda/lib/python2.7/site-packages/sklearn/multiclass.py", line 44, in <module>
from .metrics.pairwise import euclidean_distances
File "//anaconda/lib/python2.7/site-packages/sklearn/metrics/__init__.py", line 33, in <module>
from . import cluster
File "//anaconda/lib/python2.7/site-packages/sklearn/metrics/cluster/__init__.py", line 21, in <module>
from .bicluster import consensus_score
File "//anaconda/lib/python2.7/site-packages/sklearn/metrics/cluster/bicluster/__init__.py", line 1, in <module>
from .bicluster_metrics import consensus_score
File "//anaconda/lib/python2.7/site-packages/sklearn/metrics/cluster/bicluster/bicluster_metrics.py", line 6, in <module>
from sklearn.utils.validation import check_arrays
ImportError: cannot import name check_arrays
May I know what went wrong? I'll try using different environments next time, if that helps. Is there any way to fix this?
I am using Python 2.7 and sklearn 0.17.
open sklearn.utils.validation and delete "import check_arrays", or use other package for example anaconda3. i check now - no problems. Or install anaconda3.5 and copy check_arrays to anaconda2.7 sklearn.utils.validation.
Related
I want to import the "genism" library. I have previously successfully installed it by typing the following in the command prompt:
pip install gensim
However, the following error appears when importing it:
Traceback (most recent call last):
File "C:/Users/PycharmProjects/untitled/file.py", line 3, in <module>
import gensim
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\gensim\__init__.py", line 5, in <module>
from gensim import parsing, corpora, matutils, interfaces, models, similarities, summarization, utils # noqa:F401
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\gensim\parsing\__init__.py", line 4, in <module>
from .preprocessing import (remove_stopwords, strip_punctuation, strip_punctuation2, # noqa:F401
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\gensim\parsing\preprocessing.py", line 42, in <module>
from gensim import utils
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\gensim\utils.py", line 40, in <module>
import scipy.sparse
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\__init__.py", line 156, in <module>
from . import fft
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\fft\__init__.py", line 76, in <module>
from ._basic import (
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\fft\_basic.py", line 1, in <module>
from scipy._lib.uarray import generate_multimethod, Dispatchable
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\_lib\uarray.py", line 27, in <module>
from ._uarray import *
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\_lib\_uarray\__init__.py", line 114, in <module>
from ._backend import *
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\_lib\_uarray\_backend.py", line 1, in <module>
from typing import (
ImportError: cannot import name 'Type'
I have also previously successfully installed the "typing" library":
pip install typing
What should I do?
It is because Python 3.5 has its own version typing, and it is incompatible with the installed version of gensim. Upgrade to python3.6 could solve the problem.
I am running Python 3.7.0 on macOS, and I have scikit-learn version 0.20.1 installed using pip. I also have numpy and scipy installed.
When I try the following code:
from sklearn import svm
I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/sklearn/svm/__init__.py", line 13, in <module>
from .classes import SVC, NuSVC, SVR, NuSVR, OneClassSVM, LinearSVC, \
File "/usr/local/lib/python3.7/site-packages/sklearn/svm/classes.py", line 4, in <module>
from .base import _fit_liblinear, BaseSVC, BaseLibSVM
File "/usr/local/lib/python3.7/site-packages/sklearn/svm/base.py", line 11, in <module>
from ..preprocessing import LabelEncoder
File "/usr/local/lib/python3.7/site-packages/sklearn/preprocessing/__init__.py", line 6, in <module>
from ._function_transformer import FunctionTransformer
File "/usr/local/lib/python3.7/site-packages/sklearn/preprocessing/_function_transformer.py", line 5, in <module>
from ..utils.testing import assert_allclose_dense_sparse
File "/usr/local/lib/python3.7/site-packages/sklearn/utils/testing.py", line 54, in <module>
from nose.tools import raises as _nose_raises
File "/Library/Python/2.7/site-packages/nose/__init__.py", line 1, in <module>
from nose.core import collector, main, run, run_exit, runmodule
File "/Library/Python/2.7/site-packages/nose/core.py", line 153
print "%s version %s" % (os.path.basename(sys.argv[0]), __version__)
^
SyntaxError: invalid syntax
If i just import sklearn (without specifying svm), I get no errors.
Can I get help with this error please?
recently I updated packages in anaconda in order to install keras, and tensorflow. Now my program fails on the next line:
from sklearn.preprocessing import LabelEncoder, OneHotEncoder.
Traceback (most recent call last):
File "<ipython-input-1-83540d56f55d>", line 1, in <module>
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
File "/Users/teologov/anaconda/lib/python3.6/site-packages/sklearn/__init__.py", line 134, in <module>
from .base import clone
File "/Users/teologov/anaconda/lib/python3.6/site-packages/sklearn/base.py", line 13, in <module>
from .utils.fixes import signature
File "/Users/teologov/anaconda/lib/python3.6/site-packages/sklearn/utils/__init__.py", line 11, in <module>
from .validation import (as_float_array,
File "/Users/teologov/anaconda/lib/python3.6/site-packages/sklearn/utils/validation.py", line 18, in <module>
from ..utils.fixes import signature
File "/Users/teologov/anaconda/lib/python3.6/site-packages/sklearn/utils/fixes.py", line 144, in <module>
from scipy.sparse.linalg import lsqr as sparse_lsqr # noqa
File "/Users/teologov/anaconda/lib/python3.6/site-packages/scipy/sparse/linalg/__init__.py", line 114, in <module>
from .isolve import *
File "/Users/teologov/anaconda/lib/python3.6/site-packages/scipy/sparse/linalg/isolve/__init__.py", line 6, in <module>
from .iterative import *
File "/Users/teologov/anaconda/lib/python3.6/site-packages/scipy/sparse/linalg/isolve/iterative.py", line 7, in <module>
from . import _iterative
ImportError: dlopen(/Users/teologov/anaconda/lib/python3.6/site-packages/scipy/sparse/linalg/isolve/_iterative.cpython-36m-darwin.so, 2): Library not loaded: #rpath/libgfortran.3.dylib
Referenced from: /Users/teologov/anaconda/lib/python3.6/site-packages/scipy/sparse/linalg/isolve/_iterative.cpython-36m-darwin.so
Reason: image not found
Could you please help me to fix it.
Reinstallation from scratch fixed the issue, there was some conflict of versions in the installed packages.
In my case i upgrade the scikit learn package.
go to anaconda navigator then environments then search for scikit learn
then upgrade it and also upgrade scipy along with it(same process)
I am using Anaconda on ubuntu 16.04.
I try pip install tflearn on terminal and says ok.
But if I try to check the tflearn version, I receive this log.
I appreciate any hint to solve this issue.
Traceback (most recent call last):
File "/media/libardo/Datos/Proyectos/Libardo/2017/Proyectos/Kaggle/MBA/prueba_TF_Version.py", line 12, in <module>
import tflearn as tfl; print(tfl.__version__)
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tflearn/__init__.py", line 4, in <module>
from . import config
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tflearn/config.py", line 5, in <module>
from .variables import variable
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tflearn/variables.py", line 7, in <module>
from tensorflow.contrib.framework.python.ops import add_arg_scope as contrib_add_arg_scope
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/__init__.py", line 30, in <module>
from tensorflow.contrib import factorization
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/factorization/__init__.py", line 24, in <module>
from tensorflow.contrib.factorization.python.ops.gmm import *
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/factorization/python/ops/gmm.py", line 27, in <module>
from tensorflow.contrib.learn.python.learn.estimators import estimator
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/learn/__init__.py", line 87, in <module>
from tensorflow.contrib.learn.python.learn import *
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/learn/python/__init__.py", line 23, in <module>
from tensorflow.contrib.learn.python.learn import *
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/__init__.py", line 25, in <module>
from tensorflow.contrib.learn.python.learn import estimators
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/estimators/__init__.py", line 297, in <module>
from tensorflow.contrib.learn.python.learn.estimators.dnn import DNNClassifier
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/estimators/dnn.py", line 29, in <module>
from tensorflow.contrib.learn.python.learn.estimators import dnn_linear_combined
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/estimators/dnn_linear_combined.py", line 31, in <module>
from tensorflow.contrib.learn.python.learn.estimators import estimator
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 49, in <module>
from tensorflow.contrib.learn.python.learn.learn_io import data_feeder
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/learn_io/__init__.py", line 21, in <module>
from tensorflow.contrib.learn.python.learn.learn_io.dask_io import extract_dask_data
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/learn_io/dask_io.py", line 26, in <module>
import dask.dataframe as dd
File "/home/libardo/anaconda3/lib/python3.6/site-packages/dask/dataframe/__init__.py", line 3, in <module>
from .core import (DataFrame, Series, Index, _Frame, map_partitions,
File "/home/libardo/anaconda3/lib/python3.6/site-packages/dask/dataframe/core.py", line 38, in <module>
pd.computation.expressions.set_use_numexpr(False)
AttributeError: module 'pandas' has no attribute 'computation'
Maybe the pandas version is old. Try follow the following steps:
https://www.scipy.org/install.html
Another reason for your problem can be due your version of Python, like too the version of your pip. Please, verify if your pip have that libraries with:
pip list
pip2 list
pip3 list
The use of this commands depends your Python and pip version.
I have default and anaconda python, theano is installed in conda moreover it was also part of anaconda for keras. I am trying to exec a python file from another folder as python ---- and everything is ok except from theano.tensor.fft import ifft where it says no module named theano.tensor.fft I have added PYTHONPATH I have separately added theano in site-package but i can not figure out why it can not import module, please note that I can import theano.tensor I am trying to run MarcBS/keras caffe2keras.py
this is what I got when trying to install theano
Traceback (most recent call last):
File "/usr/local/bin/pip", line 7, in <module>
from pip import main
File "/usr/local/lib/python2.7/dist-packages/pip/__init__.py", line 11, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/local/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 22, in <module>
from pip._vendor import requests, six
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py", line 53, in <module>
from .packages.urllib3.contrib import pyopenssl
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/contrib/pyopenssl.py", line 70, in <module>
ssl.PROTOCOL_SSLv3: OpenSSL.SSL.SSLv3_METHOD,
AttributeError: 'module' object has no attribute 'PROTOCOL_SSLv3'