ubuntu18.04下nvidia-settings无法保存设置

问题

ubuntu18.04下nvidia-settings无法保存设置

解决方法

打开终端执行

nvidia-settings

点击 Save to X Configuration File 提示 Unable to open X config file ‘/etc/X11/xorg.conf’ for writing

看终端输出

Package xorg-server was not found in the pkg-config search path.
Perhaps you should add the directory containing `xorg-server.pc'
to the PKG_CONFIG_PATH environment variable
No package 'xorg-server' found
Package xorg-server was not found in the pkg-config search path.
Perhaps you should add the directory containing `xorg-server.pc'
to the PKG_CONFIG_PATH environment variable
No package 'xorg-server' found
Error accessing /usr/share/screen-resolution-extra/nvidia-polkit: No such file or directory

ERROR: Unable to open X config file '/etc/X11/xorg.conf' for writing.

发现没有 /usr/share/screen-resolution-extra/nvidia-polkit 文件

进入目录cd /usr/share/screen-resolution-extra && ls
发现存在nvidia-polkit.py
于是为其创建软链接,并赋予可执行权限

sudo ln -s nvidia-polkit.py nvidia-polkit
sudo chmod +x nvidia-polkit

此时,执行Save to X Configuration File,若终端输出

Package xorg-server was not found in the pkg-config search path.
Perhaps you should add the directory containing `xorg-server.pc'
to the PKG_CONFIG_PATH environment variable
No package 'xorg-server' found
Traceback (most recent call last):
  File "/usr/share/screen-resolution-extra/nvidia-polkit", line 20, in 
    import sys, dbus, logging, os, re
ImportError: No module named dbus

ERROR: Unable to open X config file '/etc/X11/xorg.conf' for writing.

可能是因为pyhon版本问题
切换系统默认python版本至python3

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150
sudo update-alternatives --display python

可看到当前选择python3

python - auto mode
  link best version is /usr/bin/python3
  link currently points to /usr/bin/python3
  link python is /usr/bin/python
/usr/bin/python2 - priority 100
/usr/bin/python3 - priority 150

此时,Save to X Configuration File应执行成功

你可能感兴趣的:(Ubuntu)