Mazze
Mazze

Reputation: 443

Installing langchain and kor in PyCharm failling due to failed building wheel for greenlet

I want to use kor and langchain in PyCharm. I import the packages using:

# kor
from kor.extraction import create_extraction_chain
from kor.nodes import Object, Text, Number

# LangChain Models
from langchain.chat_models import ChatOpenAI
from langchain.llms import OpenAI

But installing the latest versions of both packages in PyCharm I run into the same error:

  xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at:

/Library/Developer/CommandLineTools/usr/bin/xcrun error: command '/usr/bin/gcc' failed with exit code 1 [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for greenlet ERROR: Could not build wheels for greenlet, which is required to install pyproject.toml-based projects

Building greenlet on its own for my os, results in the same error. However, installing the packages in the terminal with pip works fine. The problem only occurs in PyCharm.

I use

Edit:

I tried the following in the terminal to install langchain to PyCharm

> /Users/user/PycharmProjects/test_openai/venv/bin/activate
> /Users/user/PycharmProjects/test_openai/venv/bin/python
> /Applications/PyCharm.app/Contents/plugins/python-ce/helpers/packaging_tool.py
> install langchain

It gives me, even though the file packaging_tool.py is in the directory:

can't open file /Applications/PyCharm.app/Contents/plugins/python-ce/helpers/packaging_tool.py: [Errno 2] No such file or directory

Upvotes: 1

Views: 1192

Answers (1)

edusenior
edusenior

Reputation: 1

I was getting a similar error, but in my case it was related to clang, not gcc. I was able to solve the issue by installing the XCode Command Line Tools:

xcode-select --install

greenlet has native code that requires a C compiler and associated build tools for proper installation.

Running the above command should install both clang and gcc (check by running xcode-select -p and then looking under the bin directory).

With regard to this working on the native Terminal but NOT PyCharm, I suspect that it was due to differences in the default compiler used by each tool. You can check for differences in environment variables by running env > native_env.txt and env > pycharm_env.txt in each terminal and then comparing the two with diff native_env.txt pycharm_env.txt. Check to see whether the PyCharm file has an entry for CC or CXX that may be pointing it to use gcc.

Upvotes: 0

Related Questions