使用scikit获取导入EOF错误

时间:2019-04-08 17:46:16

标签: python scikit-learn install

我已经安装了scikit-learn,并尝试从其网站运行一些代码片段,但是导入似乎引起了麻烦。使用scikit的任何代码都会不断出现EOF错误:

measurements = [
    {'city': 'Dubai', 'temperature': 33.},
    {'city': 'London', 'temperature': 12.},
    {'city': 'San Francisco', 'temperature': 18.},
]

from sklearn.feature_extraction import DictVectorizer
vec = DictVectorizer()

vec.fit_transform(measurements).toarray()




vec.get_feature_names()

我尝试了其他代码片段,错误始终相同:

py cosine.py
Traceback (most recent call last):
  File "cosine.py", line 12, in <module>
    from sklearn.feature_extraction import DictVectorizer
  File "C:\Users\haas_\Anaconda3\lib\site-packages\sklearn\feature_extraction\__init__.py", line 10, in <module>
    from . import text
  File "C:\Users\haas_\Anaconda3\lib\site-packages\sklearn\feature_extraction\text.py", line 30, in <module>
    from ..preprocessing import normalize
  File "C:\Users\haas_\Anaconda3\lib\site-packages\sklearn\preprocessing\__init__.py", line 6, in <module>
    from ._function_transformer import FunctionTransformer
  File "C:\Users\haas_\Anaconda3\lib\site-packages\sklearn\preprocessing\_function_transformer.py", line 5, in <module>
    from ..utils.testing import assert_allclose_dense_sparse
  File "C:\Users\haas_\Anaconda3\lib\site-packages\sklearn\utils\testing.py", line 751, in <module>
    import pytest
  File "C:\Users\haas_\Desktop\pytest.py", line 268

    ^
SyntaxError: unexpected EOF while parsing

似乎安装有问题?我尝试卸载然后重新安装所有内容-Numpy,Scipy,scikit-learn(始终带有pip)。我还尝试过使用Anaconda创建虚拟环境,同样的问题。

没有类似的线程帮助我解决这个问题。

感谢您的帮助。

0 个答案:

没有答案