在choregraphe中导入本地库

时间:2022-01-29 02:46:07

I am writing a block's code in choregraphe and I need some functions in numpy and pillow libraries. I installed pillow and numpy in the same folder of the behavior using pip. In choregraphe Inside the block code i tried:

我在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

and I get this error:

我收到此错误:

ImportError: cannot import name _imaging

If I comment the line

如果我评论该行

from PIL import Image

I get this error:

我收到此错误:

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

I tried to reinstall both the libraries but nothing changes. Where am I wrong? In the same folder there is also a class I wrote but don't have problems importing it, and I don't understand why

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

1 个解决方案

#1


0  

Are you running this on a robot (which one? Which OS version?), or locally on your computer?

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

If it's on a robot, chances are the .so files (and other binaries) of the libraries included in your package are not compiled for the right architecture.

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

Some possibilities:

  • Use the numpy that's already on the robot (won't help you with scipy, I don't think it's on the robot, I may be wrong tho) (I wouldn't be surprised if PIL was also already on the robot, I seem to recall seeing it but don't have a handy robot to check)
  • 使用已经在机器人上的numpy(不会帮你scipy,我不认为它在机器人上,我可能是错的)(如果PIL也已经在机器人上,我不会感到惊讶,我似乎记得看到它,但没有一个方便的机器人来检查)

  • In NAOqi 2.5, use the pip already present on the robot; but first you'll need to upgrade it:
  • 在NAOqi 2.5中,使用已存在于机器人上的点子;但首先你需要升级它:

pip install --user --upgrade pip

and then

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

Then you don't need to package those files in your choregraphe package (but you'll have to do the same procedure on all robots you want to install this to, which may or may not suit your usecase.

然后你不需要在你的choregraphe软件包中打包这些文件(但你必须在你想要安装它的所有机器人上执行相同的程序,这可能适合或不适合你的用例。

#1


0  

Are you running this on a robot (which one? Which OS version?), or locally on your computer?

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

If it's on a robot, chances are the .so files (and other binaries) of the libraries included in your package are not compiled for the right architecture.

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

Some possibilities:

  • Use the numpy that's already on the robot (won't help you with scipy, I don't think it's on the robot, I may be wrong tho) (I wouldn't be surprised if PIL was also already on the robot, I seem to recall seeing it but don't have a handy robot to check)
  • 使用已经在机器人上的numpy(不会帮你scipy,我不认为它在机器人上,我可能是错的)(如果PIL也已经在机器人上,我不会感到惊讶,我似乎记得看到它,但没有一个方便的机器人来检查)

  • In NAOqi 2.5, use the pip already present on the robot; but first you'll need to upgrade it:
  • 在NAOqi 2.5中,使用已存在于机器人上的点子;但首先你需要升级它:

pip install --user --upgrade pip

and then

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

Then you don't need to package those files in your choregraphe package (but you'll have to do the same procedure on all robots you want to install this to, which may or may not suit your usecase.

然后你不需要在你的choregraphe软件包中打包这些文件(但你必须在你想要安装它的所有机器人上执行相同的程序,这可能适合或不适合你的用例。