简体   繁体   English

在 jupyter notebook 和 google colab 中使用.so

[英]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,谢谢,

"go" is another library which you don't need i think goLibrary “go”是另一个你不需要的库,我认为goLibrary

check this if it helps pybind11检查它是否有助于pybind11

you can install pybind11 using following command您可以使用以下命令安装pybind11

!pip install pybind11 !pip 安装 pybind11

here is official reference for the same是相同的官方参考

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.

相关问题 如何使用 google colab 在 jupyter notebook 中显示 GIF? - How to display a GIF in jupyter notebook using google colab? 递归错误(Jupyter Notebook/Google Colab) - Recursion Error(Jupyter Notebook/Google Colab) 在 Jupyter Notebook 中获取 Google Colab 自动完成功能 - Get Google Colab autocomplete in Jupyter Notebook 如何在 Google Colab 上实现这个 Jupyter Notebook? - How to implement this Jupyter notebook on Google Colab? 在 Django 应用程序中嵌入 jupyter notebook/google colab - embedding jupyter notebook/ google colab in Django app 如何真正分享上传到Google Colab的Jupyter笔记本? - How to really share a Jupyter notebook uploaded to Google Colab? 在 pip 在本地安装 google-colab 后,Jupyter 笔记本卡住了 - Jupyter notebook stuck after pip install google-colab on local 在 Google Colab 平台上的 Jupyter Notebook 中显示/渲染 HTML 文件 - Display / Render an HTML file inside Jupyter Notebook on Google Colab platform 如何在 google colab(python,Jupyter notebook)中安装预定义的包(类)? - How to install a predefined package(class) in google colab(python,Jupyter notebook)? 如何将 pyscipopt 导入 Google Colab(在 Jupyter Notebook 文件中)? - How to import pyscipopt to Google Colab (in the Jupyter Notebook file)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM