问题
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