Pycharm中使用cv2无法自动补全问题

问题

在使用pycharm时发现,安装好的opencv-python,代码可以正常运行,但没有自动补全。使用时极不方便,查阅了很多博客,最终发现可以通过在Settings中增加cv2的路径解决(记录一下解决方法)。

解决方法

  1. 在Pycharm中依次打开:File -> Settings -> Project:** -> Python interpreter;
  2. 在Python interpreter栏下点击齿轮图标或下拉,选择show All;
  3. 选中你的环境,点击工具条最右边的目录形状的按钮 Show paths for the selected interpreter
  4. 点击+,将自己cv2的路径添加进去;例如:file:///home/**/anaconda3/envs/test/lib/python3.9/site-packages/cv2
  5. 确定添加后便可以实现cv2的自动补全功能啦。

新发现的问题(尚未解决)

在使用上面的方法后,cv2确实可以自动补全,但在运行时却出现了
qt.qpa.plugin: Could not find the Qt platform plugin 在删除上述添加的路径后,程序可以运行,奇怪的是cv2也可以自动补全。
莫名其妙,期待有大神解答。

你可能感兴趣的:(pycharm,python,opencv)