Python 使用pip安装pylibmc时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14803310/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error when install pylibmc using pip
提问by harristrader
Hello when I attempt to install pylibmc on OSX Lion using pip I get the following error:
您好,当我尝试使用 pip 在 OSX Lion 上安装 pylibmc 时,出现以下错误:
./_pylibmcmodule.h:42:10: fatal error: 'libmemcached/memcached.h' file not found
#include <libmemcached/memcached.h>
^
1 error generated.
error: command 'clang' failed with exit status 1
Any clues at how to solve this issue?
有关如何解决此问题的任何线索?
采纳答案by Facebook Staff are Complicit
回答by mohd
i fixed this by installing memcached from port
我通过从端口安装 memcached 解决了这个问题
you should install first macports from http://www.macports.org/
你应该从http://www.macports.org/安装第一个 macports
then run this command
然后运行这个命令
sudo port install memcached
after that download the pylibmc from the pypi http://pypi.python.org/pypi/pylibmcextract .tar.gz file then
之后从 pypi http://pypi.python.org/pypi/pylibmc下载 pylibmc 提取 .tar.gz 文件然后
python setup.py install --with-libmemcached=/opt/local
回答by Mike Fogel
It's in the libmemcached package. To install it using macports:
它在 libmemcached 包中。要使用 macports 安装它:
sudo port install libmemcached
sudo port install libmemcached
Then, assuming you're using pip:
然后,假设您正在使用 pip:
pip install pylibmc --install-option="--with-libmemcached=/opt/local"
pip install pylibmc --install-option="--with-libmemcached=/opt/local"
or
或者
LIBMEMCACHED=/opt/local pip install pylibmc
LIBMEMCACHED=/opt/local pip install pylibmc
as explained in the pylibmc docs.
回答by Giuseppe Lopes
I have the same problem because i have installed MEMCACHED and not LIBMEMCACHED, so, to resolve:
我有同样的问题,因为我安装了 MEMCACHED 而不是 LIBMEMCACHED,所以,要解决:
brew uninstall memcached #to remove wrong package
brew install libmemcached #install correct lib
pip install pylibmc
Its Works for me!
它对我有用!
: )
:)
回答by Jamie
For those finding this answer on Fedora:
对于那些在 Fedora 上找到这个答案的人:
sudo yum install libmemcached-devel
sudo yum install libmemcached-devel
回答by Twitch
Sometimes the X-Code Command Line Tools need to be installed.
有时需要安装 X-Code 命令行工具。
xcode-select -p
回答by Aidas Bendoraitis
I solved this issue by checking where memcached is installed
我通过检查 memcached 的安装位置解决了这个问题
$ which memcached
/usr/local/bin/memcached
and then setting LIBMEMCACHED environment variable before pip install:
然后在 pip install 之前设置 LIBMEMCACHED 环境变量:
$ export LIBMEMCACHED=/usr/local
$ pip install pylibmc
回答by Sarath Ak
this code is worked for me
这段代码对我有用
sudo apt-get install libmemcached-dev zlib1g-dev
LIBMEMCACHED=/opt/local pip install pylibmc
回答by Valtteri Luoma
Hit the same error with macOS High Sierra, Python3.6 installed with brew. Solution for me was to export these flags, mentioned in this comment: Error when install pylibmc using pip
使用 macOS High Sierra,使用 brew 安装的 Python3.6 遇到相同的错误。我的解决方案是导出这些标志,在此评论中提到:使用 pip 安装 pylibmc 时出错
export LDFLAGS="-L/usr/local/lib"
export CPPFLAGS="-I/usr/local/include"
After that, pip installrun just fine.
之后,pip install运行就好了。
回答by fluffy
Answer for Ubuntu users:
Ubuntu 用户的回答:
sudo apt install libmemcached-dev zlib1g-dev

