【发布时间】:2021-11-03 02:38:22
【问题描述】:
我终于开始使用除了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。
【问题讨论】:
-
您可以尝试将 jupyter notebook(在 jupyter notebook 菜单栏的“文件”选项卡下)下载到某个位置并尝试使用 pycharm 运行它,并立即显示代码和错误。我希望,我回答了你的问题
-
@PuneethGP 如果这是一个答案,你应该这样发布,而不是评论。
-
Jesse,听起来你根本不应该为你现在所做的事情编写 jupyter 笔记本——pycharm 工作得很好,不是吗?笔记本的酷炫之处在于,一旦您完成了开发,您就可以快速将可以工作的东西转换成漂亮的图形格式。用笔记本调试真的很臭。
-
我一直跟着网上教程,在来回切换和使用与导师相同的方法之间。非常感谢您的澄清。
-
@MarcusMüller 对不起兄弟,我是新来的。我学习并在使用 Stackoverflow 方面做得更好。下次我一定会发帖的
标签: python jupyter-notebook google-colaboratory