[英]Using .so in a jupyter notebook and google colab
I would like to import a library made with pybind11 in python in a jupyter notebook and a google colab.我想在 jupyter notebook 和 google colab 的 python 中导入使用 pybind11 制作的库。 the file i'm looking to import: "go.cpython-38-x86_64-linux-gnu.so" I can easily import it on a.py with "import go", but I can't do it so simply in a jupyter notebook (error when i try the 'import go': ModuleNotFoundError: No module named 'go').我要导入的文件:“go.cpython-38-x86_64-linux-gnu.so”我可以使用“import go”轻松地将它导入到 a.py 中,但我不能这么简单地在jupyter notebook(当我尝试'import go'时出错:ModuleNotFoundError: No module named 'go')。
My original goal was to import it on a google colab notebook.我最初的目标是将它导入到 google colab notebook 上。 but since that even in local it doesn't work I am first trying to understand what is going on.但因为即使在本地它也不起作用,我首先试图了解发生了什么。
I looked it over on google but I didn't find what I needed.我在谷歌上查看了它,但我没有找到我需要的东西。 If someone more experience on that topic could help me, that would be great !如果在该主题上有更多经验的人可以帮助我,那就太好了!
Thanks,谢谢,
Well you could do something like:好吧,您可以执行以下操作:
import sys
sys.path.append('<absolute_path_to_your_so_file')
if it's on colab, then I think you will need to mount it from your drive and then look for the path on that machine.如果它在 colab 上,那么我认为您需要从驱动器安装它,然后在该机器上查找路径。
Thank both of you.谢谢你们俩。
@M_x i'm not sur I understand you're message. @M_x 我不是 sur 我明白你的消息。 I compiled go with pybind11 indeed.我确实用 pybind11 编译了 go 。 it's about the Go game这是关于 Go 游戏
@Vlad Sirbu, I did that on google colab before posting this msg, but still it didn't work @Vlad Sirbu,我在发布此消息之前在 google colab 上做过,但它仍然没有用
from google.colab import drive
drive.mount('/content/gdrive')
PROJ = "/content/gdrive/My Drive/..."
import sys
sys.path.append(PROJ)
still after i have the folder i can't import the lib.仍然在我拥有文件夹之后,我无法导入库。 But i think that's a deeper issue because even in local it doesn't work.但我认为这是一个更深层次的问题,因为即使在本地它也不起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.