Table of contents
1. After installing vcxsrv, open XLauncher for configuration
4. Pick a lower version of opencv and download it again
1. Problem description
Environment used:
- School remote ubuntu server
- xshell
- pycharm
I need to run a code that is connected to the school server and needs to use the imshow method in OpenCV and cv, and then the picture display box will pop up. The following problems occur during runtime.
After consulting the information, I found that it was because the remote connection server could not return the picture. The tried solutions:
- Need to use the sudo command to install some packages on the server terminal, but I am a school server, and non-root users cannot use the sudo command;
- Then I said that I want to download XManager or MobaXterm and other remote software that supports graphics return, but the follow-up operation also needs to configure the sudo command on the server, and I can't operate it;
- The uninstall and install of pyqt5 and opencv have been carried out, and it will not work if the version is changed.
Later, I found a free software vcxsrv, which can complete the picture return from the remote server, and successfully solved the problem.
Two, the solution
Use vcxsrv to display the display content of the remote server on the local windows.
1. After installing vcxsrv, open XLauncher for configuration
VcXsrv+putty remote access to linux graphical interface - vcxserv_jdzzgtc's blog - CSDN blog
- After opening xlauncher, select multiple windows, and then be sure to change the display number below to
- Select start no client
- Tick the last item too
- Finish
- After completion, XManager will run in the background as a small window
2. Configure xshell
- Right click on your session and select properties
- Put in tunnel select forward X11 to X DISPLAY(D):localhost:0.0
3. Move the plugs folder
(I also did this step, but I don’t know if this step worked, you can ignore this step and try it)
4. Pick a lower version of opencv and download it again
I downloaded 3.4.8.29
5. Server terminal operation
Use echo $DISPLAY to display the port, and then use export DISPLAY=XX.0 on the server terminal, mine is 11.0.
echo $DISPLAY
export DISPLAY=localhost:XX.0
6.pycharm operation
Add the DISPLAY environment variable in run -> edit configurations ->enrivonment variables in pycharm, mine is DISPLAY=localhost:11.0.
7. Run successfully! ! !
If the problem of not being able to connect appears again after restarting the server, start the configuration again according to step 5, because the localhost of the connected display may have changed, just set it again.
3. Problem summary
It took me a day to finally solve this problem, it’s so touching, use the free software vcxsrv, and then configure xshell, server and pycharm