Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 安装不带root或sudo的PyYAML和libyaml_Linux_Python 2.7_Yaml_Pyyaml_Libyaml - Fatal编程技术网

Linux 安装不带root或sudo的PyYAML和libyaml

Linux 安装不带root或sudo的PyYAML和libyaml,linux,python-2.7,yaml,pyyaml,libyaml,Linux,Python 2.7,Yaml,Pyyaml,Libyaml,我需要用libyaml绑定设置PyYAML。 我正在使用5.7版的Red Hat Enterprise Linux客户端,我在/tools/Devel/epd_free-7.3-2rh5-x86_64 并在$PATH中添加了/tools/Devel/epd_free-7.3-2rh5-x86_64/bin 我正在处理此本地副本,因为我在计算机上没有root或sudo访问权限 要安装libyaml,我已完成以下操作: tar -xvzf yaml-0.1.5.tar.gz cd yaml-0.1.

我需要用libyaml绑定设置PyYAML。 我正在使用5.7版的Red Hat Enterprise Linux客户端,我在
/tools/Devel/epd_free-7.3-2rh5-x86_64
并在$PATH中添加了
/tools/Devel/epd_free-7.3-2rh5-x86_64/bin

我正在处理此本地副本,因为我在计算机上没有root或sudo访问权限

要安装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
它创造了

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

/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时,我得到了

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的位置?

在windows中使用和下载pyyaml-3.11.tar.gz对我来说很有用

然后我提取了它,打开后,我在这个位置编写了setup.py install命令


对于其他软件包,根据答案的想法在

中搜索,这些步骤对我很有用

pip install --user ruamel.yaml
然后在脚本中替换

import yaml
与:

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