问题描述
我正在使用pip并尝试安装一个名为pyodbc的python模块,该模块对非Python库(例如unixodbc-dev,unixodbc-bin,unixodbc)具有一定的依赖性.目前,由于无法正常运行,因此无法在整个系统上安装这些依赖项,因此我已将它们安装在非标准位置.如何告诉pip在哪里寻找这些依赖项?更确切地说,如何在构建pyodbc扩展时通过包含dirs(gcc -I)和库dirs(gcc -L -l)的点传递信息?
I am using pip and trying to install a python module called pyodbc which has some dependencies on non-python libraries like unixodbc-dev, unixodbc-bin, unixodbc. I cannot install these dependencies system wide at the moment, as I am only playing, so I have installed them in a non-standard location. How do I tell pip where to look for these dependencies ? More exactly, how do I pass information through pip of include dirs (gcc -I) and library dirs (gcc -L -l) to be used when building the pyodbc extension ?
推荐答案
pip具有--global-option
标志
您可以使用它将其他标志传递给build_ext
.
例如,添加--library-dirs(-L)标志:pip install --global-option=build_ext --global-option="-L/path/to/local" pyodbc
You can use it to pass additional flags to build_ext
.
For instance, to add a --library-dirs (-L) flag:pip install --global-option=build_ext --global-option="-L/path/to/local" pyodbc
gcc还支持环境变量: http://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html
gcc supports also environment variables:http://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html
我找不到任何build_ext文档,所以这是命令行帮助
I couldn't find any build_ext documentation, so here is the command line help
Options for 'build_ext' command:
--build-lib (-b) directory for compiled extension modules
--build-temp (-t) directory for temporary files (build by-products)
--plat-name (-p) platform name to cross-compile for, if supported
(default: linux-x86_64)
--inplace (-i) ignore build-lib and put compiled extensions into the
source directory alongside your pure Python modules
--include-dirs (-I) list of directories to search for header files
(separated by ':')
--define (-D) C preprocessor macros to define
--undef (-U) C preprocessor macros to undefine
--libraries (-l) external C libraries to link with
--library-dirs (-L) directories to search for external C libraries
(separated by ':')
--rpath (-R) directories to search for shared C libraries at runtime
--link-objects (-O) extra explicit link objects to include in the link
--debug (-g) compile/link with debugging information
--force (-f) forcibly build everything (ignore file timestamps)
--compiler (-c) specify the compiler type
--swig-cpp make SWIG create C++ files (default is C)
--swig-opts list of SWIG command line options
--swig path to the SWIG executable
--user add user include, library and rpath
--help-compiler list available compilers
这篇关于python pip指定一个库目录和一个include目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!