我正在使用uv
作为我的 Python 包管理器,并且我有以下命令来安装包pip
:
$ pip install pygraphviz --install-option="--include-path=/usr/include/graphviz" \
--install-option="--library-path=/usr/lib/graphviz"
我的 uv 版本是0.6.14
,而 Python 版本是3.10
。
我怎样才能实现相同的安装uv
?
我尝试过
uv 添加包
$ uv add pygraphviz
输出
× Failed to build `pygraphviz==1.14` ├─▶ The build backend returned an error ╰─▶ Call to `setuptools.build_meta.build_wheel` failed (exit status: 1) [stdout] running bdist_wheel running build running build_py ... gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall - fPIC -DSWIG_PYTHON_STRICT_BYTE_CHAR -I/root/.cache/uv/builds- v0/.tmpgLYPe0/include -I/usr/local/include/python3.12 -c pygraphviz/graphviz_wrap.c -o build/temp.linux-x86_64-cpython-312/pygraphviz/graphviz_wrap.o [stderr] ... pygraphviz/graphviz_wrap.c:9: warning: "SWIG_PYTHON_STRICT_BYTE_CHAR" redefined 9 | #define SWIG_PYTHON_STRICT_BYTE_CHAR | <command-line>: note: this is the location of the previous definition pygraphviz/graphviz_wrap.c:3023:10: fatal error: graphviz/cgraph.h: No such file or directory 3023 | #include "graphviz/cgraph.h" | ^~~~~~~~~~~~~~~~~~~ compilation terminated. error: command '/usr/bin/gcc' failed with exit code 1 hint: This error likely indicates that you need to install a library that provides "graphviz/cgraph.h" for `[email protected]`
帖子建议在
libgraphviz-dev
系统范围内安装,但由于权限限制,这对我来说不是一个选择。因此我需要知道如何指定库路径,以便将必要的文件放在我可以访问的目录中。uv 兼容 pip 命令
$ uv pip install pygraphviz --install-option="--include-path=/myfolder/include/graphviz" \ --install-option="--library-path=/myfolder/lib/graphviz"
输出
Output: error: unexpected argument '--install-option' found tip: a similar argument exists: '--reinstall' Usage: uv pip install --reinstall <PACKAGE|--requirements <REQUIREMENTS>|--editable <EDITABLE>|--group <GROUP>> For more information, try '--help'.
我认为这样做可以达到目的:
CFLAGS
代表 C 编译器标志。-I/myfolder/include/graphviz
告诉编译器头文件(.h
)。LDFLAGS
代表 Linker Flags。-L/myfolder/lib/graphviz
告诉链接器库(.so
)。