Python 导入scikit学习时出错

Python 导入scikit学习时出错,python,pip,scikit-learn,canopy,Python,Pip,Scikit Learn,Canopy,我正在尝试使用以下代码: from matplotlib import pyplot as plt from sklearn.datasets import load_iris import numpy as np 我得到这个错误: ImportError: No module named sklearn.datasets 然后我尝试安装scikit learn,但出现以下错误: pip install -U scikit-learn File "<ipython-input-9-

我正在尝试使用以下代码:

from matplotlib import pyplot as plt
from sklearn.datasets import load_iris
import numpy as np
我得到这个错误:

ImportError: No module named sklearn.datasets
然后我尝试安装scikit learn,但出现以下错误:

pip install -U scikit-learn
  File "<ipython-input-9-6d283b29f0f9>", line 1
    pip install -U scikit-learn
              ^
SyntaxError: invalid syntax


easy_install -U scikit-learn
  File "<ipython-input-10-59440c1e5ef6>", line 1
    easy_install -U scikit-learn
                         ^
SyntaxError: invalid syntax

我猜您正在尝试将这些命令放入Python命令行中。它们应该在您的操作系统终端中工作

我猜您正在尝试将这些命令放到Python命令行中。它们应该在您的操作系统终端中工作

Scikit学习包含在Canopy Basic not Express中

但正如@sashkello所指出的,您可以从OS命令行安装任何软件包,而不是此处所述的python命令行: 但是,根据您的操作系统和体验级别,您可能会发现这很困难,因为这个包不是纯Python

Scikit学习包含在Canopy Basic not Express中

但正如@sashkello所指出的,您可以从OS命令行安装任何软件包,而不是此处所述的python命令行: 但是,根据您的操作系统和体验级别,您可能会发现这很困难,因为这个包不是纯Python


我的答案是为我特定的Python版本安装这个。

我的答案是为我特定的Python版本安装这个。

我在Windows上。你是说我需要打开一个命令提示符并运行这些命令?什么目录重要吗?是的,这就是我的意思。不管是哪个目录,我在Windows上。你是说我需要打开一个命令提示符并运行这些命令?什么目录重要吗?是的,这就是我的意思。不管是哪个目录。当我在命令提示符下键入sys.prefix时,它的内容是c:\\users\\dom\\appdata\\local\\enthunk\\corporation\\user,但当我尝试easy\u install pip时,它会显示SyntaxError:无效语法并指向easy\u install pip中的最后一个p。我做错了什么?@user1477388:正如萨什凯洛所说,乔纳森用粗体字写了出来!,您正在Python控制台中键入该命令。您必须在shell中运行该命令。@DSM我在命令提示符下运行了该命令,即当我运行并键入cmd时。@user1477388:否,语法错误:无效语法是Python错误消息,而不是shell错误消息。因此,要么是您将其键入Python,要么是您给了我们错误的错误消息。@DSM谢谢,很抱歉我在启动Python的CMD中键入Python。无论如何,我安装了pip,但是,我在尝试安装scikit learn时出错。我在编辑问题时发布了相关日志。当我在命令提示符中键入sys.prefix时,它显示为c:\\users\\dom\\appdata\\local\\enthund\\corporation\\user,但当我尝试easy\u install pip时,它显示SyntaxError:无效语法并指向easy\u install pip中的最后一个p。我做错了什么?@user1477388:正如萨什凯洛所说,乔纳森用粗体字写了出来!,您正在Python控制台中键入该命令。您必须在shell中运行该命令。@DSM我在命令提示符下运行了该命令,即当我运行并键入cmd时。@user1477388:否,语法错误:无效语法是Python错误消息,而不是shell错误消息。因此,要么是您将其键入Python,要么是您给了我们错误的错误消息。@DSM谢谢,很抱歉我在启动Python的CMD中键入Python。无论如何,我安装了pip,但是,我在尝试安装scikit learn时出错。我在我的编辑中发布了相关日志。
running build_clib

No module named msvccompiler in numpy.distutils; trying from distutils

customize MSVCCompiler

Missing compiler_cxx fix for MSVCCompiler

customize MSVCCompiler using build_clib

building 'libsvm-skl' library

compiling C sources

Partial import of sklearn during the build process.

C:\Users\cle1394\AppData\Local\Enthought\Canopy\User\lib\site-packages\numpy\distutils\system_info.py:564: UserWarning: Specified path C:\Users\vagrant\src\master-env\libs is invalid.

  warnings.warn('Specified path %s is invalid.' % d)

C:\Users\cle1394\AppData\Local\Enthought\Canopy\User\lib\site-packages\numpy\distutils\system_info.py:564: UserWarning: Specified path C:\Users\vagrant\src\master-env\include is invalid.

  warnings.warn('Specified path %s is invalid.' % d)

C:\Users\cle1394\AppData\Local\Enthought\Canopy\User\lib\site-packages\numpy\distutils\system_info.py:1494: UserWarning:

    Atlas (http://math-atlas.sourceforge.net/) libraries not found.

    Directories to search for the libraries can be specified in the

    numpy/distutils/site.cfg file (section [atlas]) or by setting

    the ATLAS environment variable.

  warnings.warn(AtlasNotFoundError.__doc__)

C:\Users\cle1394\AppData\Local\Enthought\Canopy\User\lib\site-packages\numpy\distutils\system_info.py:1503: UserWarning:

    Blas (http://www.netlib.org/blas/) libraries not found.

    Directories to search for the libraries can be specified in the

    numpy/distutils/site.cfg file (section [blas]) or by setting

    the BLAS environment variable.

  warnings.warn(BlasNotFoundError.__doc__)

C:\Users\cle1394\AppData\Local\Enthought\Canopy\User\lib\site-packages\numpy\distutils\system_info.py:1506: UserWarning:

    Blas (http://www.netlib.org/blas/) sources not found.

    Directories to search for the sources can be specified in the

    numpy/distutils/site.cfg file (section [blas_src]) or by setting

    the BLAS_SRC environment variable.

  warnings.warn(BlasSrcNotFoundError.__doc__)

sklearn\svm\setup.py:58: UserWarning:

    Blas (http://www.netlib.org/blas/) libraries not found.

    Directories to search for the libraries can be specified in the

    numpy/distutils/site.cfg file (section [blas]) or by setting

    the BLAS environment variable.

  warnings.warn(BlasNotFoundError.__doc__)

sklearn\setup.py:77: UserWarning:

    Blas (http://www.netlib.org/blas/) libraries not found.

    Directories to search for the libraries can be specified in the

    numpy/distutils/site.cfg file (section [blas]) or by setting

    the BLAS environment variable.

  warnings.warn(BlasNotFoundError.__doc__)

error: Unable to find vcvarsall.bat

----------------------------------------

Cleaning up...

  Removing temporary dir c:\users\cle1394\appdata\local\temp\pip_build_cle1394...
Command C:\Users\cle1394\AppData\Local\Enthought\Canopy\User\Scripts\python.exe -c "import setuptools;__file__='c:\\users\\cle1394\\appdata\\local\\temp\\pip_build_cle1394\\scikit-learn\\setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\cle1394\appdata\local\temp\pip-1ysfly-record\install-record.txt --single-version-externally-managed failed with error code 1 in c:\users\cle1394\appdata\local\temp\pip_build_cle1394\scikit-learn

Exception information:
Traceback (most recent call last):
  File "C:\Users\cle1394\AppData\Local\Enthought\Canopy\User\lib\site-packages\pip-1.4.1-py2.7.egg\pip\basecommand.py", line 134, in main
    status = self.run(options, args)
  File "C:\Users\cle1394\AppData\Local\Enthought\Canopy\User\lib\site-packages\pip-1.4.1-py2.7.egg\pip\commands\install.py", line 241, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "C:\Users\cle1394\AppData\Local\Enthought\Canopy\User\lib\site-packages\pip-1.4.1-py2.7.egg\pip\req.py", line 1298, in install
    requirement.install(install_options, global_options, *args, **kwargs)
  File "C:\Users\cle1394\AppData\Local\Enthought\Canopy\User\lib\site-packages\pip-1.4.1-py2.7.egg\pip\req.py", line 625, in install
    cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
  File "C:\Users\cle1394\AppData\Local\Enthought\Canopy\User\lib\site-packages\pip-1.4.1-py2.7.egg\pip\util.py", line 670, in call_subprocess
    % (command_desc, proc.returncode, cwd))
InstallationError: Command C:\Users\cle1394\AppData\Local\Enthought\Canopy\User\Scripts\python.exe -c "import setuptools;__file__='c:\\users\\cle1394\\appdata\\local\\temp\\pip_build_cle1394\\scikit-learn\\setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\cle1394\appdata\local\temp\pip-1ysfly-record\install-record.txt --single-version-externally-managed failed with error code 1 in c:\users\cle1394\appdata\local\temp\pip_build_cle1394\scikit-learn