首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不带超级用户或sudo安装PyYAML和libyaml

不带超级用户或sudo安装PyYAML和libyaml
EN

Stack Overflow用户
提问于 2014-06-12 00:02:21
回答 2查看 2.1K关注 0票数 2

我需要用libyaml绑定设置PyYAML。我正在使用一个带有5.7版的Red Hat Enterprise Linux客户端,我在/tools/Devel/epd_free-7.3-2rh5-x86_64下安装了一个本地副本,并将/tools/Devel/epd_free-7.3-2rh5-x86_64/bin添加到了$PATH中

我正在处理这个本地副本,因为我在机器上没有root或sudo访问权限。

要安装libyaml,我已经这样做了:

代码语言:javascript
复制
tar -xvzf yaml-0.1.5.tar.gz
cd yaml-0.1.5
./configure prefix=/tools/Devel/epd_free-7.3-2-rh5-x86_64
make
make install

它已经创建了

代码语言:javascript
复制
/tools/Devel/epd_free-7.3-2rh5-x86_64/include/yaml.h

以及

代码语言:javascript
复制
/tools/Devel/epd_free-7.3-2rh5-x86_64/lib/libyaml-0.so.2
/tools/Devel/epd_free-7.3-2rh5-x86_64/lib/libyaml-0.so.2.0.3
/tools/Devel/epd_free-7.3-2rh5-x86_64/lib/libyaml.a
/tools/Devel/epd_free-7.3-2rh5-x86_64/lib/libyaml.la
/tools/Devel/epd_free-7.3-2rh5-x86_64/lib/libyaml.so
/tools/Devel/epd_free-7.3-2rh5-x86_64/lib/pkgconfig

但是,当我尝试安装PyYAML时,我得到

代码语言:javascript
复制
pip install PyYAML

Downloading/unpacking PyYAML
  Downloading PyYAML-3.11.tar.gz (248kB): 248kB downloaded
  Running setup.py (path:/tmp/pip_build_greglac/PyYAML/setup.py) egg_info for package PyYAML

Installing collected packages: PyYAML
  Running setup.py install for PyYAML
    checking if libyaml is compilable
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -O2 -fPIC -I/tools/Devel/epd_free-7.3-2-rh5-x86_64/include/python2.7 -c build/temp.linux-x86_64-2.7/check_libyaml.c -o build/temp.linux-x86_64-2.7/check_libyaml.o
    build/temp.linux-x86_64-2.7/check_libyaml.c:2:18: error: yaml.h: No such file or directory
    build/temp.linux-x86_64-2.7/check_libyaml.c: In function âmainâ:
    build/temp.linux-x86_64-2.7/check_libyaml.c:5: error: âyaml_parser_tâ undeclared (first use in this function)
    build/temp.linux-x86_64-2.7/check_libyaml.c:5: error: (Each undeclared identifier is reported only once
    build/temp.linux-x86_64-2.7/check_libyaml.c:5: error: for each function it appears in.)
    build/temp.linux-x86_64-2.7/check_libyaml.c:5: error: expected â;â before âparserâ
    build/temp.linux-x86_64-2.7/check_libyaml.c:6: error: âyaml_emitter_tâ undeclared (first use in this function)
    build/temp.linux-x86_64-2.7/check_libyaml.c:6: error: expected â;â before âemitterâ
    build/temp.linux-x86_64-2.7/check_libyaml.c:8: error: âparserâ undeclared (first use in this function)
    build/temp.linux-x86_64-2.7/check_libyaml.c:11: error: âemitterâ undeclared (first use in this function)

    libyaml is not found or a compiler error: forcing --without-libyaml
    (if libyaml is installed correctly, you may need to
     specify the option --include-dirs or uncomment and
     modify the parameter include_dirs in setup.cfg)

Successfully installed PyYAML
Cleaning up...

我认为这是因为PyYAML在缺省位置查找libyaml。有没有办法为pyyaml安装指定libyaml的位置?

EN

回答 2

Stack Overflow用户

发布于 2015-08-01 16:53:36

使用https://pypi.python.org/simple/pyyaml/并下载PyYAML-3.11.tar.gz在windows中对我有效

然后我将其解压缩,并在打开后将命令setup.py install写入以下位置

有关其他软件包的信息,请在https://pypi.python.org/simple中搜索

票数 0
EN

Stack Overflow用户

发布于 2017-07-12 20:59:27

基于答案here的想法,这些步骤对我很有效

代码语言:javascript
复制
pip install --user ruamel.yaml

然后在脚本中替换

代码语言:javascript
复制
import yaml

通过以下方式:

代码语言:javascript
复制
from ruamel.yaml import YAML
yaml=YAML(typ='safe')
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24167549

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档