1
resposta

Erro a instalar LangChain

Bom dia. Estou com erro na instalação do Langchain. Parece que está tendo algum conflito com Numpy

Collecting numpy==1.26.4
  Using cached numpy-1.26.4.tar.gz (15.8 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 2
  ╰─> [35 lines of output]
      + C:\Users\luciano\OneDrive\Área de Trabalho\PYTHON\langchain\.venv\Scripts\python.exe C:\Users\luciano\AppData\Local\Temp\pip-install-rn_ynikn\numpy_45c868f061c24d408f662f3be871304f\vendored-meson\meson\meson.py setup C:\Users\luciano\AppData\Local\Temp\pip-install-rn_ynikn\numpy_45c868f061c24d408f662f3be871304f C:\Users\luciano\AppData\Local\Temp\pip-install-rn_ynikn\numpy_45c868f061c24d408f662f3be871304f\.mesonpy-zwt8xqf9 -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=C:\Users\luciano\AppData\Local\Temp\pip-install-rn_ynikn\numpy_45c868f061c24d408f662f3be871304f\.mesonpy-zwt8xqf9\meson-python-native-file.ini
      Traceback (most recent call last):
        File "C:\Users\luciano\AppData\Local\Temp\pip-install-rn_ynikn\numpy_45c868f061c24d408f662f3be871304f\vendored-meson\meson\mesonbuild\mesonmain.py", line 194, in run
          return options.run_func(options)
                 ~~~~~~~~~~~~~~~~^^^^^^^^^
        File "C:\Users\luciano\AppData\Local\Temp\pip-install-rn_ynikn\numpy_45c868f061c24d408f662f3be871304f\vendored-meson\meson\mesonbuild\msetup.py", line 358, in run
          app.generate()
          ~~~~~~~~~~~~^^
        File "C:\Users\luciano\AppData\Local\Temp\pip-install-rn_ynikn\numpy_45c868f061c24d408f662f3be871304f\vendored-meson\meson\mesonbuild\msetup.py", line 178, in generate
          env = environment.Environment(self.source_dir, self.build_dir, self.options)
        File "C:\Users\luciano\AppData\Local\Temp\pip-install-rn_ynikn\numpy_45c868f061c24d408f662f3be871304f\vendored-meson\meson\mesonbuild\environment.py", line 571, in __init__
          config = coredata.parse_machine_files(self.coredata.config_files)
        File "C:\Users\luciano\AppData\Local\Temp\pip-install-rn_ynikn\numpy_45c868f061c24d408f662f3be871304f\vendored-meson\meson\mesonbuild\coredata.py", line 1032, in parse_machine_files
          parser = MachineFileParser(filenames)
        File "C:\Users\luciano\AppData\Local\Temp\pip-install-rn_ynikn\numpy_45c868f061c24d408f662f3be871304f\vendored-meson\meson\mesonbuild\coredata.py", line 973, in __init__
          self.parser.read(filenames)
          ~~~~~~~~~~~~~~~~^^^^^^^^^^^
        File "C:\Users\luciano\AppData\Local\Temp\pip-install-rn_ynikn\numpy_45c868f061c24d408f662f3be871304f\vendored-meson\meson\mesonbuild\coredata.py", line 960, in read
          return super().read(filenames, encoding)
                 ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\luciano\AppData\Local\Programs\Python\Python313\Lib\configparser.py", line 735, in read
          self._read(fp, filename)
          ~~~~~~~~~~^^^^^^^^^^^^^^
        File "C:\Users\luciano\AppData\Local\Programs\Python\Python313\Lib\configparser.py", line 1050, in _read
          ParsingError._raise_all(self._read_inner(fp, fpname))
                                  ~~~~~~~~~~~~~~~~^^^^^^^^^^^^
        File "C:\Users\luciano\AppData\Local\Programs\Python\Python313\Lib\configparser.py", line 1058, in _read_inner
          for st.lineno, line in enumerate(map(Line, fp), start=1):
                                 ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
        File "<frozen codecs>", line 325, in decode
      UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc1 in position 50: invalid start byte

      ERROR: Unhandled python exception

          This is a Meson bug and should be reported!
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
1 resposta

Olá, Luciano, como vai?

Acredito que esse erro está relacionado à versão 3.13 do Python. Vi relatos de outros usuários enfrentando problemas similares em instalações de outras bibliotecas. Uma solução comum é fazer o downgrade para a versão 3.12, que está mais estável.

Testei a instalação com essa versão e funcionou normalmente! Você pode fazer o download no site oficial do Python e configurar a virtualenv novamente.

Se precisar de mais ajuda com a instalação ou o downgrade, é só avisar.

Espero ter ajudado!

Siga firme nos seus estudos e conte com o fórum sempre que precisar!

Abraços :)

Caso este post tenha lhe ajudado, por favor, marcar como solucionado