简体   繁体   中英

I cannot import sklearn.model_selection.train_test_split

When I want to import sklearn.model_selection, I get this error:

     17 from ._split import check_cv
     18 
---> 19 from ._validation import cross_val_score
     20 from ._validation import cross_val_predict
     21 from ._validation import cross_validate

/usr/local/lib/python3.6/dist-packages/sklearn/model_selection/_validation.py in <module>
     29 from ..utils._joblib import logger
     30 from ..externals.six.moves import zip
---> 31 from ..metrics.scorer import check_scoring, _check_multimetric_scoring
     32 from ..exceptions import FitFailedWarning
     33 from ._split import check_cv

/usr/local/lib/python3.6/dist-packages/sklearn/metrics/__init__.py in <module>
      5 
      6 
----> 7 from .ranking import auc
      8 from .ranking import average_precision_score
      9 from .ranking import coverage_error

/usr/local/lib/python3.6/dist-packages/sklearn/metrics/ranking.py in <module>
     25 import numpy as np
     26 from scipy.sparse import csr_matrix
---> 27 from scipy.stats import rankdata
     28 
     29 from ..utils import assert_all_finite

/usr/local/lib/python3.6/dist-packages/scipy/stats/__init__.py in <module>
    343 from .stats import *
    344 from .distributions import *
--> 345 from .morestats import *
    346 from ._binned_statistic import *
    347 from .kde import gaussian_kde

/usr/local/lib/python3.6/dist-packages/scipy/stats/morestats.py in <module>
     10                    sqrt, ceil, floor, array, compress,
     11                    pi, exp, ravel, count_nonzero, sin, cos, arctan2, hypot)
---> 12 from numpy.testing.decorators import setastest
     13 
     14 from scipy._lib.six import string_types

ModuleNotFoundError: No module named 'numpy.testing.decorators'

numpy version: 1.18.3, sklearn version: 0.20.0, python version: 3.6.8

I want to run my code on a server and I do not have admin rights to reinstall python or sklearn.

Make sure you have all the requirement. Some modules require extra software to be installed. Such as a C++ compiler for some. If you are using Linux a simple command such as python yourmodule.py could work as well. So just double check the instructions and make sure you are doing everything right because installing modules can be very fishy and hard. And for the Admin rights: If you are having a company hosting this server for you then you may have to get the rights from them or it may be impossible if they don't allow it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM