Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

baetyl中功能函数(.py)无法引入第三方依赖包问题 #407

Closed
zhaoxu6666 opened this issue Nov 11, 2019 · 1 comment
Closed

Comments

@zhaoxu6666
Copy link

zhaoxu6666 commented Nov 11, 2019

Describe the bug
baetyl基于树莓派4代B型Raspbian操作系统对功能函数(.py)调用时出现无法引用依赖包问题

To Reproduce
image

Expected behavior
成功的引用依赖包(机器学习相关的依赖包numpu、pandas等等)来实现所需功能

Screenshots
image

OS-platform (please complete the following information):

  • OS: Raspbian
  • CPU: Cortex A-72
  • Baetyl Version [0.1.5]
  • 本机:armv7l GNU/Linux
@kuailehaibin
Copy link
Member

kuailehaibin commented Nov 14, 2019

@zhaoxu6666 你好!首先,非常感谢您提出的问题!针对您提出的问题,我们做了实际测试。实际测试脚本中引入了 pandasscikit-learn 机器学习库,通过 pip download <libpackage> 命令我们可以发现 pandasscikit-learn 的依赖如下:

pip download pandas
pip download scikit-learn

执行完后可以发现,pandas 主要依赖 numpydateutilpytzsix 等库;scikit-learn 主要依赖 numpyscipyjoblib 等库。

参考 文档,通常只要把下载的依赖库解压与测试脚本放在同一目录下,并以 package 形式引入即可。

但是,实际测试来看,在 Raspberry pi 4 model B 上的确出现了问题截图中的异常,经查询资料发现,pandasscikit-learn 安装使用除了上述已列出的第三方库外,还对与系统相关的 Cython 库有依赖(单独编译 pandasscikit-learn 库会有相应提示),需要在具备 Cython 环境的基础上才能正确使用;此外,scikit-learn 依赖的 scipy 的构建和安装需要依赖发行版系统。要在没有预编译所需库软件包的操作系统上构建 SciPynumpy 同理),必须先构建然后静态链接到 Fortran 库 BLASLAPACK

image

因此,对于 pandasscikit-learn 库的使用不能参考普通第三方库引入的方式。这里提供一个建议:可以在我们官方提供的 Python runtime Dockerfile 的基础上直接把所需要的特殊第三方库(如 pandasscikit-learn)在打包、构建的容器镜像时引入。

相关资料可参考:
[1] https://stackoverflow.com/questions/14570011/explain-why-numpy-should-not-be-imported-from-source-directory
[2] https://stackoverflow.com/questions/7496547/does-python-scipy-need-blas
[3] https://docs.scipy.org/doc/scipy-1.1.0/reference/building/linux.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants