PyYAML:如何指定包含目录?
PyYAML: how to specify an include directory?
我构建了 libyaml 并将其安装到本地:
yaml-0.1.5 $ ./configure --prefix=/usr/local/sqlminus
yaml-0.1.5 $ make install
yaml-0.1.5 $ ls -l /usr/local/sqlminus/include/yaml.h
-rw-r--r--@ 1 mh admin 54225 Jan 5 09:05 /usr/local/sqlminus/include/yaml.h
但是当我构建 PyYAML 时,它找不到 yaml.h。
PyYAML-3.11 $ /usr/local/sqlminus/bin/python setup.py build
checking if libyaml is compilable
gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall
-Wstrict-prototypes -I/usr/local/sqlminus/include/python2.7
-c build/temp.macosx-10.4-x86_64-2.7/check_libyaml.c
-o build/temp.macosx-10.4-x86_64-2.7/check_libyaml.o
build/temp.macosx-10.4-x86_64-2.7/check_libyaml.c:2:10:
fatal error: 'yaml.h'
file not found
#include <yaml.h>
^
1 error generated.
如何告诉 PyYAML 我在哪里安装了 libyaml?
(更新) 根据下面 dotslash 的评论,编辑 setup.cfg 并添加这两行使一切顺利进行。
include_dirs=/usr/local/sqlminus/include
library_dirs=/usr/local/sqlminus/lib
(结束更新)
我认为你应该安装依赖项。
如果您正在使用 Ubuntu 或基于 Debian 的系统,您可以通过此搜索
apt-cache search libyaml
然后你可能会发现有一些相关的包。
我建议你尝试安装这个:apt-get install libyaml-dev -y
如果你使用Mac OS,你可以更改文件check_libyaml.c
中的源代码,告诉它yaml.h的绝对路径是什么是。
或者编译时指定路径
python setup.py config --with-includepath=/path/to/your/install/of/python/includes/
然后去编译。
可以找到更多信息 here。
希望对您有所帮助。
根据 dotslash 的评论,编辑 setup.cfg
并添加这两行使一切顺利进行:
include_dirs=/usr/local/sqlminus/include
library_dirs=/usr/local/sqlminus/lib
我构建了 libyaml 并将其安装到本地:
yaml-0.1.5 $ ./configure --prefix=/usr/local/sqlminus
yaml-0.1.5 $ make install
yaml-0.1.5 $ ls -l /usr/local/sqlminus/include/yaml.h
-rw-r--r--@ 1 mh admin 54225 Jan 5 09:05 /usr/local/sqlminus/include/yaml.h
但是当我构建 PyYAML 时,它找不到 yaml.h。
PyYAML-3.11 $ /usr/local/sqlminus/bin/python setup.py build
checking if libyaml is compilable
gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall
-Wstrict-prototypes -I/usr/local/sqlminus/include/python2.7
-c build/temp.macosx-10.4-x86_64-2.7/check_libyaml.c
-o build/temp.macosx-10.4-x86_64-2.7/check_libyaml.o
build/temp.macosx-10.4-x86_64-2.7/check_libyaml.c:2:10:
fatal error: 'yaml.h'
file not found
#include <yaml.h>
^
1 error generated.
如何告诉 PyYAML 我在哪里安装了 libyaml?
(更新) 根据下面 dotslash 的评论,编辑 setup.cfg 并添加这两行使一切顺利进行。
include_dirs=/usr/local/sqlminus/include
library_dirs=/usr/local/sqlminus/lib
(结束更新)
我认为你应该安装依赖项。
如果您正在使用 Ubuntu 或基于 Debian 的系统,您可以通过此搜索
apt-cache search libyaml
然后你可能会发现有一些相关的包。
我建议你尝试安装这个:apt-get install libyaml-dev -y
如果你使用Mac OS,你可以更改文件check_libyaml.c
中的源代码,告诉它yaml.h的绝对路径是什么是。
或者编译时指定路径
python setup.py config --with-includepath=/path/to/your/install/of/python/includes/
然后去编译。
可以找到更多信息 here。
希望对您有所帮助。
根据 dotslash 的评论,编辑 setup.cfg
并添加这两行使一切顺利进行:
include_dirs=/usr/local/sqlminus/include
library_dirs=/usr/local/sqlminus/lib