benman1 / generative_ai_with_langchain

Build large language model (LLM) apps with Python, ChatGPT and other models. This is the companion repository for the book on generative AI with LangChain.
https://amzn.to/43PuIkQ
MIT License
583 stars 239 forks source link

Issues installing dependencies on ubuntu 24 #61

Open audaxland opened 1 week ago

audaxland commented 1 week ago

I am having issues installing dependencies on ubuntu 24.04.1

I am trying to run

pip install -r requirements.txt

on a virtual environment

python --version
Python 3.11.10

and I am getting the error

ERROR: Could not build wheels for wikipedia, langdetect, sgmllib3k, which is required to install pyproject.toml-based projects

I seem to need to install additional dependencies, but I'm not finding what..

audaxland commented 1 week ago

And Docker also has some isssues

running

docker build -t langchain_ai .

gives the error

 > [4/8] COPY notebooks ./notebooks:
------
Dockerfile:10
--------------------
   8 |     # Update the environment:
   9 |     COPY requirements.txt .
  10 | >>> COPY notebooks ./notebooks
  11 |     
  12 |     # I was sometimes running into errors with hashes:
--------------------
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref 20ca653f-6d08-4af8-a866-accd615a4946::s35c2a2xowf0r5k8fonwqqjqt: "/notebooks": not found
benman1 commented 1 week ago

Thanks, @audaxland for reporting this. I can't replicate the exact issue with pip. When I use conda to set up an environment, it works for me (but MacOS):

conda create -n dummy python=3.11
conda activate dummy
pip install -r requirements.txt

Takes less than 10 minutes on my laptop.

benman1 commented 1 week ago

Hi again, @audaxland. Thanks for pointing out the problem with the Dockerfile. The notebook folder has been removed in the new version of the repo/book. I've just fixed that and the file location when copying. It's working for me. Please let me know if you have any further trouble.

docker build -t langchain_ai .
docker run -it -p 8888:8888 langchain_ai
audaxland commented 1 week ago

Hi, again,

I'm not using conda, I'm using:

git clone https://github.com/benman1/generative_ai_with_langchain.git
cd generative_ai_with_langchain
virtualenv -p python3.11 .venv
source .venv/bin/activate
python --version
Python 3.11.10
pip install -r requirements.txt

the official version of python for ubuntu 24 is python 3.12 so I have both versions installed.

Some of the errors that it is throwing ares :

Building wheels for collected packages: wikipedia, langdetect, sgmllib3k
  Building wheel for wikipedia (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [74 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib
      creating build/lib/wikipedia
      copying wikipedia/exceptions.py -> build/lib/wikipedia
      copying wikipedia/__init__.py -> build/lib/wikipedia
      copying wikipedia/util.py -> build/lib/wikipedia
      copying wikipedia/wikipedia.py -> build/lib/wikipedia
      /datalinux/dev/learn/books/generative_langchain/generative_ai_with_langchain/.venv/lib/python3.11/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
      !!

              ********************************************************************************
              Please avoid running ``setup.py`` directly.
              Instead, use pypa/build, pypa/installer or other
              standards-based tools.

              See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
              ********************************************************************************

      !!
        self.initialize_options()
      installing to build/bdist.linux-x86_64/wheel
      running install
      running install_lib

....

        File "/datalinux/dev/learn/books/generative_langchain/generative_ai_with_langchain/.venv/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 107, in __getattr__
          raise AttributeError(attr)
      AttributeError: install_layout. Did you mean: 'install_platlib'?
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for wikipedia
  Running setup.py clean for wikipedia
  Building wheel for langdetect (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [193 lines of output]
      running bdist_wheel
      running build
      running build_py

....

     adding license file 'LICENSE'
      adding license file 'NOTICE'
      writing manifest file 'langdetect.egg-info/SOURCES.txt'
      /datalinux/dev/learn/books/generative_langchain/generative_ai_with_langchain/.venv/lib/python3.11/site-packages/setuptools/command/build_py.py:204: _Warning: Package 'langdetect.profiles' is absent from the `packages` configuration.
      !!

              ********************************************************************************
              ############################
              # Package would be ignored #
              ############################
              Python recognizes 'langdetect.profiles' as an importable package[^1],
              but it is absent from setuptools' `packages` configuration.

              This leads to an ambiguous overall configuration. If you want to distribute this
              package, please make sure that 'langdetect.profiles' is explicitly added
              to the `packages` configuration field.

              Alternatively, you can also rely on setuptools' discovery methods
              (for example by using `find_namespace_packages(...)`/`find_namespace:`
              instead of `find_packages(...)`/`find:`).

              You can read more about "package discovery" on setuptools documentation page:

              - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html

              If you don't want 'langdetect.profiles' to be distributed and are
              already explicitly excluding 'langdetect.profiles' via
              `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`,
              you can try to use `exclude_package_data`, or `include-package-data=False` in
              combination with a more fine grained `package-data` configuration.

              You can read more about "package data files" on setuptools documentation page:

              - https://setuptools.pypa.io/en/latest/userguide/datafiles.html

              [^1]: For Python, any directory (with suitable naming) can be imported,
                    even if it does not contain any `.py` files.
                    On the other hand, currently there is no concept of package data
                    directory, all directories are treated like packages.
              ********************************************************************************

      !!
        check.warn(importable)
      creating build/lib/langdetect/profiles

....

     copying langdetect/utils/messages.properties -> build/lib/langdetect/utils
      /datalinux/dev/learn/books/generative_langchain/generative_ai_with_langchain/.venv/lib/python3.11/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
      !!

              ********************************************************************************
              Please avoid running ``setup.py`` directly.
              Instead, use pypa/build, pypa/installer or other
              standards-based tools.

              See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
              ********************************************************************************

      !!
        self.initialize_options()
      installing to build/bdist.linux-x86_64/wheel
      running install
      running install_lib

...

     AttributeError: install_layout. Did you mean: 'install_platlib'?
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for langdetect
  Running setup.py clean for langdetect
  Building wheel for sgmllib3k (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [70 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib
      copying sgmllib.py -> build/lib
      /datalinux/dev/learn/books/generative_langchain/generative_ai_with_langchain/.venv/lib/python3.11/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
      !!

              ********************************************************************************
              Please avoid running ``setup.py`` directly.
              Instead, use pypa/build, pypa/installer or other
              standards-based tools.

              See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
              ********************************************************************************

....

     AttributeError: install_layout. Did you mean: 'install_platlib'?
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for sgmllib3k
  Running setup.py clean for sgmllib3k
Failed to build wikipedia langdetect sgmllib3k
ERROR: Could not build wheels for wikipedia, langdetect, sgmllib3k, which is required to install pyproject.toml-based projects
audaxland commented 1 week ago

Docker seems to work now, thanks

benman1 commented 1 week ago

Hey @audaxland. Thanks for testing this and for the detailed description and output. I have tested your commands above for installing with pip and virtualenv, and for me it's working. The only difference is that I have Python 3.11.3. I assume the difference is due to Linux vs MacOS dependencies (building wheels for wikipedia, langdetect, sgmllib3k) - that's a bit harder to test for me. Great to hear docker is working though.