简体   繁体   English

在没有root或sudo的情况下安装PyYAML和libyaml

[英]installing PyYAML and libyaml without root or sudo

I need to setup PyYAML with the libyaml bindings. 我需要使用libyaml绑定设置PyYAML。 I'm working on a Red Hat Enterprise Linux Client with release 5.7 and I have a local copy of Enthought Python 7.3.2 installed under /tools/Devel/epd_free-7.3-2rh5-x86_64 and have added /tools/Devel/epd_free-7.3-2rh5-x86_64/bin to $PATH 我正在使用5.7版的Red Hat Enterprise Linux客户端,并且在/tools/Devel/epd_free-7.3-2rh5-x86_64下安装了Enthought Python 7.3.2的本地副本,并添加了/tools/Devel/epd_free-7.3-2rh5-x86_64/bin至$ PATH

I'm working on this local copy since I don't have root or sudo access on the machine. 我正在使用此本地副本,因为我在计算机上没有root或sudo访问权限。

To install libyaml I have done: 要安装libyaml,我已经完成了:

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

which has created 创造了

/tools/Devel/epd_free-7.3-2rh5-x86_64/include/yaml.h

as well as 以及

/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

However when I try to install PyYAML I get 但是,当我尝试安装PyYAML时,我得到了

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...

I assume this is because PyYAML is looking for libyaml in the default location. 我认为这是因为PyYAML在默认位置寻找libyaml。 Is there away to specify the location of libyaml for the pyyaml install? 是否可以指定pyyaml安装的libyaml位置?

use https://pypi.python.org/simple/pyyaml/ and downloading PyYAML-3.11.tar.gz worked for me in windows 使用https://pypi.python.org/simple/pyyaml/并下载PyYAML-3.11.tar.gz在Windows中为我工作

then i extracted it and after opening i wrote the command setup.py install in this location 然后我解压缩它,打开后我在此位置写了命令setup.py install

for other packages search in https://pypi.python.org/simple 对于其他软件包, https://pypi.python.org/simple中搜索

Based on the idea of the answer here these steps worked for me 根据此处答案的思想,这些步骤对我有用

pip install --user ruamel.yaml

then replace in your script 然后替换您的脚本

import yaml

with: 有:

from ruamel.yaml import YAML
yaml=YAML(typ='safe')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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