sentencepiece: Pip install sentencepiece failure
Hi,
pip install sentencepiece
fails,
This is the log I get:
pip install sentencepiece 7.4.0 Collecting sentencepiece Using cached https://files.pythonhosted.org/packages/fd/45/6d0eb609d5cd81df094aab71a867b2ab6b315ffd592e78fb94a625c4d6aa/sentencepiece-0.1.3.tar.gz ERROR: Complete output from command python setup.py egg_info: ERROR: /bin/sh: 1: pkg-config: not found Failed to find sentencepiece pkgconfig ---------------------------------------- ERROR: Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-install-463tj_x8/sentencepiece/
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 19
- Comments: 43
For Apple M1 / ARM: Run these on default terminal (not sure if all packages are required):
Then run this on rosetta emulated terminal (maybe the default terminal will work too):
pip3 install sentencepiece
I find a solution works for me.
Just:
pip install --upgrade pip
Env: python: 3.7.2 Release: 8.11 Codename: jessieJust
brew install cmake
fixed the issue for me, thanks @ni9elf. Ran on default terminal window tooI come with this problem !
hardware: Apple Macbook M1 Python 3.9.4 (default, Apr 4 2021, 17:42:23) git clone https://github.com/google/sentencepiece.git cd python python3 setup.py install
logs as blew: /opt/homebrew/lib/python3.9/site-packages/setuptools/dist.py:642: UserWarning: Usage of dash-separated ‘description-file’ will not be supported in future versions. Please use the underscore name ‘description_file’ instead warnings.warn( running install running bdist_egg running egg_info writing src/sentencepiece.egg-info/PKG-INFO writing dependency_links to src/sentencepiece.egg-info/dependency_links.txt writing top-level names to src/sentencepiece.egg-info/top_level.txt reading manifest file ‘src/sentencepiece.egg-info/SOURCES.txt’ reading manifest template ‘MANIFEST.in’ writing manifest file ‘src/sentencepiece.egg-info/SOURCES.txt’ installing library code to build/bdist.macosx-11-arm64/egg running install_lib running build_py running build_ext Package sentencepiece was not found in the pkg-config search path. Perhaps you should add the directory containing
sentencepiece.pc' to the PKG_CONFIG_PATH environment variable No package 'sentencepiece' found mkdir: bundled: File exists fatal: destination path 'sentencepiece' already exists and is not an empty directory. fatal: destination path 'sentencepiece' already exists and is not an empty directory. mkdir: build: File exists ./build_bundled.sh: line 15: cmake: command not found ./build_bundled.sh: line 16: nproc: command not found make: *** No targets specified and no makefile found. Stop. make: *** No rule to make target
install’. Stop. Package sentencepiece was not found in the pkg-config search path. Perhaps you should add the directory containing `sentencepiece.pc’ to the PKG_CONFIG_PATH environment variable No package ‘sentencepiece’ found Failed to find sentencepiece pkg-configNone of this worked until I found this comment: https://github.com/google/sentencepiece/issues/608#issuecomment-1276909623
seems to have finally done it…
So
and then finally for Huggingface
pip3 install 'transformers[tf-cpu]'
to work, I had to also install Rust next…Finally…!
One more data point for M1 users: I used the default terminal to run
And that did it for me.
conda install sentencepiece
works for meI don’t know which package helped me out. but after installing these packages my problem solved:
It comes from the Build and install SentencePiece command line tools from C++ source section of the README.md
This is how I’ve fixed the problem on this particular server: Python 3.11.0, Ubuntu 20.04 (focal):
So basically I provided all necessary building tools to build
sentencepiece
from scratch, referring to @taku910 clarification:Seems the valid binary whl package is not downloaded and the fallback src package is fetched instead.
Personally, I didn’t want to depend on a boundary case for a specific scenario, but to keep generic installation
Same here, only happens on Python 3.7.4 for me, works on Python 3.6. Observed on Ubuntu 16.04.4
Also on M1 - this worked for me
I confirm that installing cmake on Macos Ventura
it allows me to install correctly
sentencepiece
python moduleThank you!
I solved this first by running the below command
and then running
pip install sentencepiece
again.I have a M2 Macbook Pro and works after apply this thread!
Just want to add up probably might help. I switched to python version
3.9
and worked! I was actually at3.10
when I did this and got those error.pip3 install --upgrade pip it works for me
For anyone on Mac M1 this indeed fixed the issue:
I first tried:
didn’t work so then I did:
and indeed it worked 🎉🎉🎉
It worked solving the M2 issues too! Thanks, man!
I am Windows with Intel, but this also solved the issue for me:
pip install cmake
My goal was to install FlairNLP, which relies on sentencepiece to run. After poking around at this problem for a while, this is what worked for me. I have a MacOS, I am using zsh, and I have Python 3.10.5. After activating my virtual environment, I ran the following command:
pip3 install --only-binary sentencepiece flair
I think this worked because the installation kept getting stuck on the step where it had to build a wheel for the sentencepiece dependency:
Building wheels for collected packages: sentencepiece Building wheel for sentencepiece (setup.py) … error error: subprocess-exited-with-error
So I read this article about Python wheels and figured I’d force pip to use wheels instead of source distributions for sentencepiece. Hope this helps!
#After installation cmake and pkg-config , I got this error
Package sentencepiece was not found in the pkg-config search path. Perhaps you should add the directory containing `sentencepiece.pc’ to the PKG_CONFIG_PATH environment variable No package ‘sentencepiece’ found Failed to find sentencepiece pkgconfig
@mprinc,
A very big THANK YOU!
Kind regards.
The pip install worked for a while but I got this
Here was how I solved (partially). So I’m on Raspberry Pi 4 (armv7l GNU/Linux).
Installing Transformers, unable to install sentencepiece due to: “Failed to find sentencepiece pkgconfig”
I went deep into the cause, -------- First install from source: $ wget https://github.com/google/sentencepiece $ cd sentencepiece/python/ -------- Then try to install package (so folders are created): $ sudo python3 setup.py install -------- This will rise the error for me ERROR: Package sentencepiece was not found in the pkg-config search path. Perhaps you should add the directory containing `sentencepiece.pc’ to the PKG_CONFIG_PATH environment variable No package ‘sentencepiece’ found Failed to find sentencepiece pkgconfig" -------- excecute in terminal the individual set of commands $ cmake -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ … -DSPM_ENABLE_SHARED=OFF -DCMAKE_INSTALL_PREFIX=…/… $ make -stdlib=libstdc++ -j $(nproc) $ make install --------- once sentencepiece was installed $ python3 import sentencepiece ------- witch then rise a different error: Traceback (most recent call last): File “<stdin>”, line 1, in <module> File “/home/work/non.conflict/venv/lib/python3.7/site-packages/sentencepiece-0.1.94-py3.7-linux-armv7l.egg/sentencepiece/init.py”, line 13, in <module> from . import _sentencepiece ImportError: /home/work/non.conflict/venv/lib/python3.7/site-packages/sentencepiece-0.1.94-py3.7-linux-armv7l.egg/sentencepiece/_sentencepiece.cpython-37m-arm-linux-gnueabihf.so: undefined symbol: __atomic_fetch_add_8 --------- gives this error, but at now i’m able to import transformers import transformers