Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for MacOS / poetry "Cannot install torch" issue #10

Open
tb opened this issue Aug 28, 2024 · 1 comment
Open

Workaround for MacOS / poetry "Cannot install torch" issue #10

tb opened this issue Aug 28, 2024 · 1 comment

Comments

@tb
Copy link

tb commented Aug 28, 2024

I was not able to start the project on MacOS

➜  langchain-crash-course git:(main) ✗ sw_vers
ProductName:		macOS
ProductVersion:		14.6.1
BuildVersion:		23G93

Error I get:

➜  langchain-crash-course git:(main) ✗ poetry install --no-root
Installing dependencies from lock file

Package operations: 12 installs, 1 update, 0 removals

  - Updating torch (2.2.2 -> 2.3.1): Failed

  RuntimeError

  Unable to find installation candidates for torch (2.3.1)

  at ~/.pyenv/versions/3.11.6/lib/python3.11/site-packages/poetry/installation/chooser.py:74 in choose_for
       70│
       71│             links.append(link)
       72│
       73│         if not links:
    →  74│             raise RuntimeError(f"Unable to find installation candidates for {package}")
       75│
       76│         # Get the best link
       77│         chosen = max(links, key=lambda link: self._sort_key(package, link))
       78│

Cannot install torch.

I tried https://stackoverflow.com/a/76359919/478584 but it did not help.

Workaround:

python -m venv venv
source venv/bin/activate
pip install python-dotenv langchain langchain-community langchain-openai langchain-anthropic langchain-google-genai langchain-google-firestore firestore chromadb tiktoken sentence-transformers bs4 firecrawl-py langchainhub wikipedia tavily-python

NOTE: pip installed torch-2.2.2-cp311-none-macosx_10_9_x86_64.whl

@anupsd
Copy link

anupsd commented Sep 19, 2024

I was able to fix it properly by running:
poetry add https://files.pythonhosted.org/packages/3f/14/e105b8ef6d324e789c1589e95cb0ab63f3e07c2216d68b1178b7c21b7d2a/torch-2.2.2-cp311-none-macosx_10_9_x86_64.whl

using the following pyproject.toml file:
`
[tool.poetry]
name = "langchain-crash-course"
version = "0.1.0"
description = "Everything you need to know to get started with LangChain"
authors = ["anup"]

[tool.poetry.dependencies]
python = ">=3.10.0,<3.12"
langchain-openai = "^0.2.0"
python-dotenv = "^1.0.1"
langchain = "^0.3.0"
langchain-community = "^0.3.0"
langchain-anthropic = "^0.2.1"
langchain-google-genai = "^2.0.0"
langchain-google-firestore = "^0.3.0"
firestore = "^0.0.8"
chromadb = "^0.5.0"
tiktoken = "^0.7.0"
sentence-transformers = "^3.0.0"
bs4 = "^0.0.2"
firecrawl-py = "^1.2.3"
langchainhub = "^0.1.18"
wikipedia = "^1.4.0"
tavily-python = "^0.5.0"
pkgconfig="1.5.5"
torch = {url = "https://files.pythonhosted.org/packages/3f/14/e105b8ef6d324e789c1589e95cb0ab63f3e07c2216d68b1178b7c21b7d2a/torch-2.2.2-cp311-none-macosx_10_9_x86_64.whl"}

[tool.pyright]

https://github.com/microsoft/pyright/blob/main/docs/configuration.md

useLibraryCodeForTypes = true
exclude = [".cache"]

[tool.ruff]

https://beta.ruff.rs/docs/configuration/

select = ['E', 'W', 'F', 'I', 'B', 'C4', 'ARG', 'SIM']
ignore = ['W291', 'W292', 'W293']

[build-system]
requires = ["poetry-core=1.0.0"]
build-backend = "poetry.core.masonry.api"

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@tb @anupsd and others