CV2 Cannot connect to X server:

ⅰ亾dé卋堺 提交于 2019-12-12 14:01:47

问题


When I try to use cv2.imshow(), I get an error saying that it can't conect to X server. I'm running this locally, using bash in Windows Command Prompt. No servers, no VPNS, etc.

Python 3.4, CV2 3.4

img = cv2.imread(fileName)
cv2.imshow("Image", img)
cv2.waitKey(0)

回答1:


Encountered the same issue with bash on windows. had to install OpenCV using conda install instead. everything worked fine after the install. check out the anaconda page for details here. if you do have anaconda already you can run the code below in cmd to install opencv.

conda install -c conda-forge OpenCV  

P.S: be sure to set anaconda as base in cmd by running the command else conda wont work.

C:\Users\{name}\Anaconda3\Scripts\activate base


来源:https://stackoverflow.com/questions/53357075/cv2-cannot-connect-to-x-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!