[英]How to use opencv in a remote jupyter notebook execution?
In my local machine with macOS Mojave, I installed a virtual environment with Python 3.6, opencv package and some additional unrelated packages. 在我使用macOS Mojave的本地机器上,我安装了一个带有Python 3.6,opencv软件包和一些其他不相关软件包的虚拟环境。
I started a very simple Jupyter Notebook that is executed with no problem, here it's the code: 我启动了一个非常简单的Jupyter Notebook,它执行起来没有问题,这是代码:
import cv2
print(cv2.__version__)
my_img = cv2.imread("colibri_763_460.jpeg",1)
cv2.imshow("Original", my_img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Now, I'm trying to execute the same code in a Jupyter Notebook in my remote Ubuntu machine but I can't make it work. 现在,我正在尝试在我的远程Ubuntu机器中的Jupyter Notebook中执行相同的代码,但我无法使其工作。 These are the steps that I took:
这些是我采取的步骤:
I tried to solve my problem using two different ways: 我试图用两种不同的方式解决我的问题:
Does anyone know if there's any way to execute the remote jupyter notebook and see the picture locally? 有人知道是否可以执行远程jupyter笔记本并在本地查看图片吗? it maybe would be possible a workaround to embed the picture in the browser window?
也许可以通过一种解决方法将图片嵌入浏览器窗口?
Thank you very much Marcos Pastor 非常感谢Marcos Pastor
I wonder if the image is being rendered using X - which you have not explicitly enabled, in both your host machine, nor in your ssh tunnel. 我想知道在你的主机和ssh隧道中是否使用X渲染图像 - 你没有明确启用它。
On the Host machine. 在主机上。 (Where you want to see the Image).
(你想在哪里看到图像)。 Enter this comment
输入此评论
xhost+
This now allows remote X-Hosts to send you data. 现在,这允许远程X-Hosts向您发送数据。 As you are on a Mac - you will need to have the XQuartz package installed.
当您使用Mac时 - 您需要安装XQuartz软件包。
Now modify your ssh command. 现在修改你的ssh命令。 - so that you allow X - this is typically done using a -X flag (Or it can be placed in your .ssh/config file like this
- 这样你就允许X - 这通常使用-X标志来完成(或者它可以放在你的.ssh / config文件中
Host *
ForwardX11 yes
ForwardX11Trusted no
XAuthLocation /opt/X11/bin/xauth
ForwardAgent yes
Compression yes
KeepAlive yes
Compression yes
If you are not using a config try the -X to start with. 如果您没有使用配置,请尝试使用-X开头。
Hope that helps 希望有所帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.