Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pycharm Startup Error: Unable to detect graphics environment

I'm trying to setup Pycharm professional edition on Fedora 25 x64. After downloading the files and extracting them, I'm trying to run the script ./pycharm.sh in the bin directory. This is the error I get:

Startup Error: Unable to detect graphics environment

I have checked my Java version

[root@localhost bin]# java -version
openjdk version "1.8.0_144"
OpenJDK Runtime Environment (build 1.8.0_144-b01)
OpenJDK 64-Bit Server VM (build 25.144-b01, mixed mode)

I tried as well to set the DISPLAY variable:

export DISPLAY=:0 

And this is what I get:

[root@localhost bin]# ./pycharm.sh 
No protocol specified

Start Failed: Failed to initialize graphics environment

java.awt.AWTError: Can't connect to X11 window server using ':0' as the value of the DISPLAY variable.

Any suggestions please ?

like image 532
Joseph Wahba Avatar asked Sep 08 '17 20:09

Joseph Wahba


2 Answers

I had the same error installing in a clean Ubuntu 17.10, with Gnome on Wayland. At @mattdm's suggestion in your comments, I just opened a new terminal (as myself, not root) and it ran fine. I was running as root (after unpacking everything to /opt/) when I got the error.

mike@feynman:~$ /opt/pycharm/bin/pycharm.sh

Once you register/activate, just click the "* Configure v" pulldown from the welcome window, and select "Create Desktop Entry" to make it available from your OS menus. I'm assuming JetBrains made this work for whichever linux flavor you prefer.

like image 153
mightypile Avatar answered Nov 05 '22 07:11

mightypile


Your X environment is not properly set (manually setting DISPLAY doesn't always work). Possibly because you're attempting this as root and root is not the owner of the graphics session. There could be other reasons, too.

You won't be able to run xclock or any other X app either in this situation - this is the clue that it's not a pycharm-related problem. For example if you ssh to localhost as root, not as the user currently logged in into the graphical session:

laptop:~ # ssh localhost
Password: 
Last login: Thu Nov 23 22:19:06 2017 from localhost
Have a lot of fun...
laptop:~ # export DISPLAY=:0
laptop:~ # xclock
No protocol specified
Error: Can't open display: :0
laptop:~ # konsole
No protocol specified
Segmentation fault
laptop:~ # pycharm
OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=350m; support was removed in 8.0
No protocol specified

Start Failed: Failed to initialize graphics environment

You'd also see the same behaviour if you attempt the same in a text-mode console.

To address this issue open a new terminal from the graphics environment - if it is properly installed you should be able to run any of the X apps, including pycharm (or at least it shouldn't fail with that error).

like image 5
Dan Cornilescu Avatar answered Nov 05 '22 05:11

Dan Cornilescu