简体   繁体   中英

python-Levenshtein library install error on MacOS

I am trying to install a package on a python project but having some issues with python-Levenshtein library. I'm using a virtual environment on PyCharm which is running with Python3.8 and installed all libraries in requirements.txt with pip. However I am not able to install this library.

What I've tried so far:

  1. try to install with pip and pip3
  2. try to install with anaconda
  3. try to install with brew (to make sure it's not like matplotlib here )

I share the error message below. Could you help me to solve this problem

Collecting python-Levenshtein==0.12.0
  Using cached python-Levenshtein-0.12.0.tar.gz (48 kB)
Requirement already satisfied: setuptools in /Users/suleyman/Projects/venv/lib/python3.8/site-packages (from python-Levenshtein==0.12.0) (51.1.1)
Building wheels for collected packages: python-Levenshtein
  Building wheel for python-Levenshtein (setup.py): started
  Building wheel for python-Levenshtein (setup.py): finished with status 'error'
  Running setup.py clean for python-Levenshtein
Failed to build python-Levenshtein
Installing collected packages: python-Levenshtein
    Running setup.py install for python-Levenshtein: started
    Running setup.py install for python-Levenshtein: finished with status 'error'

  ERROR: Command errored out with exit status 1:

You can just do python3 -m pip install python-levenshtein or if you want to install system-wide just do the sudo -H python3 -m pip install python-levenshtein .

PS It works for me. 在此处输入图像描述

I've found the solution and explain it for those who suffers from the same thing. Macbook comes with its own python in usr/bin/python and user/bin/python3 and first I used them as base interpreter however I faced that issue. I think default pythons don't include some essentials.

The solution is installing your python and giving its path as the base interpreter. After that pip is able to install the library.

在此处输入图像描述

That solved my issue and I am able to install my libraries.

Try installing libpython3.8-dev (see this post )

I was running into the same build error on Ubuntu 18.04 until I ran

sudo apt install libpython3.8-dev

Then, inside my python virtual environment, I ran

python3 -m pip install python-Levenshtein

If that doesn't work, check that you have build-essential installed. If not, then try:

sudo apt install build-essential

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM