python指定库路径_python pip指定库目录和包含目录

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 has a --global-option flag

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

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值