python - 共享 Jupyter 细胞
问题描述
除了pycharm之外,我终于开始使用jupyter notebook。但是,我发现从 jupyter 将代码粘贴到 stackoverflow 上更加麻烦。
我有以下错误
---------------------------------------------------------------------------
error Traceback (most recent call last)
<ipython-input-78-9346139ce50d> in <module>
1 blurred = cv2.medianBlur(img, 5)
----> 2 grey_blur = cv2.cvtColor(blurred, cv2.cv2.COLOR_BGR2GRAY)
3 thresh = cv2.adaptiveThreshold(grey_blur, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 15, 5)
4 combined = cv2.bitwise_and(new_image, new_image, mask=thresh)
5 cv2.imshow("cartoon Lau blk shrt", combined)
error: OpenCV(4.5.3) c:\users\runneradmin\appdata\local\temp\pip-req-build-c2l3r8zm\opencv\modules\imgproc\src\color.simd_helpers.hpp:92: error: (-2:Unspecified error) in function '__cdecl cv::impl::`anonymous-namespace'::CvtHelper<struct cv::impl::`anonymous namespace'::Set<3,4,-1>,struct cv::impl::A0xb6623f80::Set<1,-1,-1>,struct cv::impl::A0xb6623f80::Set<0,2,5>,2>::CvtHelper(const class cv::_InputArray &,const class cv::_OutputArray &,int)'
> Invalid number of channels in input image:
> 'VScn::contains(scn)'
> where
> 'scn' is 1
除了报错信息,我想把整个代码贴出来,但是不想每个单元格都经过和crtl+c,crtl+v,好像过分了
我想尊重每个人在 stackoverflow 上的时间,并在理解最佳实践方面寻求帮助。
1-我听说从 VS Code 运行 jupyter 是一种选择,但还没有尝试过。
2-有没有办法直接从 jupyter 本身分享或者我应该查看 VS 代码?
3-也许还有另一个选项可以共享整个项目的链接
我已尝试下载 .py 文件。我能够将它拖到 PyCharm 中,但格式仍然关闭
# In[ ]:
image = cv2.imread('C:\\Users\\holli\\OneDrive\\Pictures\\python photos\\lau black short changing room, haair.jpg')
image.shape
# In[ ]:
x,y,z= image.shape
# In[ ]:
plt.imshow(image)
所以,在这一点上,我现在将坚持使用 PyCharm。
解决方案
单击一个单元格以将其选中。
Shift+单击另一个单元格以选择该单元格和其间的所有单元格。
按只是
C
复制单元格输入(这是一个 jupyter 快捷方式)。这应该适用于复制到其他笔记本中,但您也可以将其粘贴到任何其他编辑器或 Stack Overflow 帖子中。
我不知道复制单元格输出的特定方法。它是网络浏览器中的所有文本,因此常规方法可以正常工作。
推荐阅读
- ios - View Controller only 协议无权访问 View Controller 属性
- azure - Azure 自定义转换器大小限制
- java - 添加到 Java 枚举的新值在调试期间不可用
- java - 我应该在 try-with-resources 语句中声明每个资源吗?
- java - 如何要求用户重新输入他们的选择?
- android - Android Volley StringRequest 有时不工作
- reactjs - 如何从我的 React 应用程序调用 netlify lambda 函数?
- angular - 添加工具提示的角度侧栏不起作用
- python - 使用 one-hot 编码处理 sklearn 中的分类变量
- dns - 有人可以告诉我在验证我的域时我做错了什么吗?