在choregraphe中导入本地库

时间:2018-03-17 17:24:13

标签: python scipy python-imaging-library choregraphe

我在choregraphe中编写了一个块代码,我需要在numpy和pillow库中使用一些函数。我使用pip将枕头和numpy安装在相同的行为文件夹中。在choregraphe里面我尝试了块代码:

from sys import path
path.append(ALFrameManager.getBehaviorPath(self.behaviorId))
from PIL import Image
from scipy import array, inf
from scipy.sparse.csgraph import shortest_path, csgraph_from_dense

我收到此错误:

ImportError: cannot import name _imaging

如果我评论该行

from PIL import Image

我收到此错误:

ImportError: 
Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control).  Otherwise reinstall numpy.

Original error was: cannot import name multiarray

我尝试重新安装这两个库,但没有任何改变。我哪里错了?在同一个文件夹中还有一个我写的类,但没有导入它的问题,我不明白为什么

1 个答案:

答案 0 :(得分:0)

您是在机器人(哪一个?哪个操作系统版本?)或计算机本地运行?

如果它在机器人上,那么包中包含的库的.so文件(和其他二进制文件)可能不会针对正确的体系结构进行编译。

一些可能性:

  • 使用机器人已经存在的numpy(赢得了scipy的帮助,我不认为它在机器人上,我可能是错的)(I如果PIL也已经在机器人上,我不会感到惊讶,我似乎记得看到它,但没有一个方便的机器人来检查)
  • 在NAOqi 2.5中,使用已存在于机器人上的点子;但首先你需要升级它:
pip install --user --upgrade pip

然后

/home/nao/.local/bin/pip install --user scipy (or whatever other package you need)

然后您不需要将这些文件打包到您的choregraphe包中(但是您必须对要安装它的所有机器人执行相同的操作,这可能适用于您的用例,也可能不适合您的用例