Solucionado (ver solução)
Solucionado
(ver solução)
3
respostas

erro ao executar arquivo

Ao executar o código para match, encontro esse erro

Traceback (most recent call last):
  File "classificacao.py", line 13, in <module>
    from sklearn.naive_bayes import MultinomialNB
  File "C:\Python35\lib\site-packages\sklearn\__init__.py", line 57, in <module>
    from .base import clone
  File "C:\Python35\lib\site-packages\sklearn\base.py", line 10, in <module>
    from scipy import sparse
ImportError: No module named 'scipy'

instalei corretamente o scikit-learn, não sei o qque deve ter ocorrido, esse é o meu código:

# eh gordinho? tem perninha curta? se faz au au?
porco1 = [1, 1, 0]
porco2 = [1, 1, 0]
porco3 = [1, 1, 0]
cachorro1 = [1, 1, 1]
cachorro2 = [0, 1, 1]
cachorro3 = [0, 1, 1]

dados = [porco1, porco2, porco3, cachorro1, cachorro2, cachorro3]

marcacoes = [1, 1, 1, -1, -1, -1]

from sklearn.naive_bayes import MultinomialNB

modelo = MultinomialNB()
modelo.fit(dados, marcacoes)

misterioso1 = [1, 1, 1]
misterioso2 = [1, 0, 0]
misterioso3 = [0, 1, 1]
teste = [misterioso1, misterioso2, misterioso3]
print(modleo.predict(teste))
3 respostas
solução!

Opa Roberto, será que essa dúvida pode te ajudar => https://cursos.alura.com.br/forum/topico-erro-ao-rodar-classificacao-py-29100 ?

Boa noite tentei executei os comandos do tópico e link, na instalação do scipy deu erro no CMD

pip install --user scipy
Collecting scipy
  Using cached scipy-0.18.1.tar.gz
Building wheels for collected packages: scipy
  Running setup.py bdist_wheel for scipy ... error
  Complete output from command c:\python35\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\User\\AppData\\Local\\Temp\\pip-build-yf82b_8z\\scipy\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\User\AppData\Local\Temp\tmpp4st76uhpip-wheel- --python-tag cp35:
  lapack_opt_info:
  openblas_lapack_info:
    libraries openblas not found in ['c:\\python35\\lib', 'C:\\', 'c:\\python35\\libs']
    NOT AVAILABLE

  lapack_mkl_info:
    libraries mkl_rt not found in ['c:\\python35\\lib', 'C:\\', 'c:\\python35\\libs']
    NOT AVAILABLE

  atlas_3_10_threads_info:
  Setting PTATLAS=ATLAS
  c:\python35\lib\site-packages\numpy\distutils\system_info.py:639: UserWarning: Specified path C:\projects\numpy-wheels\windows-wheel-builder\atlas-builds\atlas-3.11.38-sse2-64\lib is invalid.
    warnings.warn('Specified path %s is invalid.' % d)
  <class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
    NOT AVAILABLE

  atlas_3_10_info:
  <class 'numpy.distutils.system_info.atlas_3_10_info'>
    NOT AVAILABLE

  atlas_threads_info:
  Setting PTATLAS=ATLAS
  <class 'numpy.distutils.system_info.atlas_threads_info'>
    NOT AVAILABLE

  atlas_info:
  <class 'numpy.distutils.system_info.atlas_info'>
    NOT AVAILABLE

  c:\python35\lib\site-packages\numpy\distutils\system_info.py:1532: 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__)
  lapack_info:
    libraries lapack not found in ['c:\\python35\\lib', 'C:\\', 'c:\\python35\\libs']
    NOT AVAILABLE

  c:\python35\lib\site-packages\numpy\distutils\system_info.py:1543: UserWarning:
      Lapack (http://www.netlib.org/lapack/) libraries not found.
      Directories to search for the libraries can be specified in the
      numpy/distutils/site.cfg file (section [lapack]) or by setting
      the LAPACK environment variable.
    warnings.warn(LapackNotFoundError.__doc__)
  lapack_src_info:
    NOT AVAILABLE

  c:\python35\lib\site-packages\numpy\distutils\system_info.py:1546: UserWarning:
      Lapack (http://www.netlib.org/lapack/) sources not found.
      Directories to search for the sources can be specified in the
      numpy/distutils/site.cfg file (section [lapack_src]) or by setting
      the LAPACK_SRC environment variable.
    warnings.warn(LapackSrcNotFoundError.__doc__)
    NOT AVAILABLE

  Running from scipy source directory.
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\User\AppData\Local\Temp\pip-build-yf82b_8z\scipy\setup.py", line 415, in <module>
      setup_package()
    File "C:\Users\User\AppData\Local\Temp\pip-build-yf82b_8z\scipy\setup.py", line 411, in setup_package
      setup(**metadata)
    File "c:\python35\lib\site-packages\numpy\distutils\core.py", line 135, in setup
      config = configuration()
    File "C:\Users\User\AppData\Local\Temp\pip-build-yf82b_8z\scipy\setup.py", line 335, in configuration
      config.add_subpackage('scipy')
    File "c:\python35\lib\site-packages\numpy\distutils\misc_util.py", line 1000, in add_subpackage
      caller_level = 2)
    File "c:\python35\lib\site-packages\numpy\distutils\misc_util.py", line 969, in get_subpackage
      caller_level = caller_level + 1)
    File "c:\python35\lib\site-packages\numpy\distutils\misc_util.py", line 906, in _get_configuration_from_setup_py
      config = setup_module.configuration(*args)
    File "scipy\setup.py", line 15, in configuration
      config.add_subpackage('linalg')
    File "c:\python35\lib\site-packages\numpy\distutils\misc_util.py", line 1000, in add_subpackage
      caller_level = 2)
    File "c:\python35\lib\site-packages\numpy\distutils\misc_util.py", line 969, in get_subpackage
      caller_level = caller_level + 1)
    File "c:\python35\lib\site-packages\numpy\distutils\misc_util.py", line 906, in _get_configuration_from_setup_py
      config = setup_module.configuration(*args)
    File "scipy\linalg\setup.py", line 20, in configuration
      raise NotFoundError('no lapack/blas resources found')
  numpy.distutils.system_info.NotFoundError: no lapack/blas resources found

  ----------------------------------------
  Failed building wheel for scipy
  Running setup.py clean for scipy
  Complete output from command c:\python35\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\User\\AppData\\Local\\Temp\\pip-build-yf82b_8z\\scipy\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" clean --all:

  `setup.py clean` is not supported, use one of the following instead:

    - `git clean -xdf` (cleans all files)
    - `git clean -Xdf` (cleans all versioned files, doesn't touch
                        files that aren't checked into the git repo)

  Add `--force` to your command to use it anyway if you must (unsupported).


  ----------------------------------------
  Failed cleaning build dir for scipy
Failed to build scipy
Installing collected packages: scipy
  Running setup.py install for scipy ... error
    Complete output from command c:\python35\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\User\\AppData\\Local\\Temp\\pip-build-yf82b_8z\\scipy\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\User\AppData\Local\Temp\pip-qjk_2ldv-record\install-record.txt --single-version-externally-managed --compile --user --prefix=:

    Note: if you need reliable uninstall behavior, then install
    with pip instead of using `setup.py install`:

      - `pip install .`       (from a git repo or downloaded source
                               release)
      - `pip install scipy`   (last SciPy release on PyPI)


    lapack_opt_info:
    openblas_lapack_info:
      libraries openblas not found in ['c:\\python35\\lib', 'C:\\', 'c:\\python35\\libs']
      NOT AVAILABLE

    lapack_mkl_info:
      libraries mkl_rt not found in ['c:\\python35\\lib', 'C:\\', 'c:\\python35\\libs']
      NOT AVAILABLE

    atlas_3_10_threads_info:
    Setting PTATLAS=ATLAS
    c:\python35\lib\site-packages\numpy\distutils\system_info.py:639: UserWarning: Specified path C:\projects\numpy-wheels\windows-wheel-builder\atlas-builds\atlas-3.11.38-sse2-64\lib is invalid.
      warnings.warn('Specified path %s is invalid.' % d)
    <class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
      NOT AVAILABLE

    atlas_3_10_info:
    <class 'numpy.distutils.system_info.atlas_3_10_info'>
      NOT AVAILABLE

    atlas_threads_info:
    Setting PTATLAS=ATLAS
    <class 'numpy.distutils.system_info.atlas_threads_info'>
      NOT AVAILABLE

    atlas_info:
    <class 'numpy.distutils.system_info.atlas_info'>
      NOT AVAILABLE

    c:\python35\lib\site-packages\numpy\distutils\system_info.py:1532: 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__)
    lapack_info:
      libraries lapack not found in ['c:\\python35\\lib', 'C:\\', 'c:\\python35\\libs']
      NOT AVAILABLE

    c:\python35\lib\site-packages\numpy\distutils\system_info.py:1543: UserWarning:
        Lapack (http://www.netlib.org/lapack/) libraries not found.
        Directories to search for the libraries can be specified in the
        numpy/distutils/site.cfg file (section [lapack]) or by setting
        the LAPACK environment variable.
      warnings.warn(LapackNotFoundError.__doc__)
    lapack_src_info:
      NOT AVAILABLE

    c:\python35\lib\site-packages\numpy\distutils\system_info.py:1546: UserWarning:
        Lapack (http://www.netlib.org/lapack/) sources not found.
        Directories to search for the sources can be specified in the
        numpy/distutils/site.cfg file (section [lapack_src]) or by setting
        the LAPACK_SRC environment variable.
      warnings.warn(LapackSrcNotFoundError.__doc__)
      NOT AVAILABLE

    Running from scipy source directory.
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\User\AppData\Local\Temp\pip-build-yf82b_8z\scipy\setup.py", line 415, in <module>
        setup_package()
      File "C:\Users\User\AppData\Local\Temp\pip-build-yf82b_8z\scipy\setup.py", line 411, in setup_package
        setup(**metadata)
      File "c:\python35\lib\site-packages\numpy\distutils\core.py", line 135, in setup
        config = configuration()
      File "C:\Users\User\AppData\Local\Temp\pip-build-yf82b_8z\scipy\setup.py", line 335, in configuration
        config.add_subpackage('scipy')
      File "c:\python35\lib\site-packages\numpy\distutils\misc_util.py", line 1000, in add_subpackage
        caller_level = 2)
      File "c:\python35\lib\site-packages\numpy\distutils\misc_util.py", line 969, in get_subpackage
        caller_level = caller_level + 1)
      File "c:\python35\lib\site-packages\numpy\distutils\misc_util.py", line 906, in _get_configuration_from_setup_py
        config = setup_module.configuration(*args)
      File "scipy\setup.py", line 15, in configuration
        config.add_subpackage('linalg')
      File "c:\python35\lib\site-packages\numpy\distutils\misc_util.py", line 1000, in add_subpackage
        caller_level = 2)
      File "c:\python35\lib\site-packages\numpy\distutils\misc_util.py", line 969, in get_subpackage
        caller_level = caller_level + 1)
      File "c:\python35\lib\site-packages\numpy\distutils\misc_util.py", line 906, in _get_configuration_from_setup_py
        config = setup_module.configuration(*args)
      File "scipy\linalg\setup.py", line 20, in configuration
        raise NotFoundError('no lapack/blas resources found')
    numpy.distutils.system_info.NotFoundError: no lapack/blas resources found

    ----------------------------------------
Command "c:\python35\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\User\\AppData\\Local\\Temp\\pip-build-yf82b_8z\\scipy\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\User\AppData\Local\Temp\pip-qjk_2ldv-record\install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in C:\Users\User\AppData\Local\Temp\pip-build-yf82b_8z\scipy\

Estou usando o ambiente Windows para os testes

No outro tópico consegui mais detalhes e resolvi esse erro