运行命令 Cmake 时权限被拒绝

运行命令 Cmake 时权限被拒绝

我正在使用 Ubuntu 20.04。当我运行命令时,cmake --version出现权限被拒绝错误,如下所示:

 :
Traceback (most recent call last):
  File "/usr/local/bin/cmake", line 11, in <module>
    load_entry_point('cmake==3.18.4.post1', 'console_scripts', 'cmake')()
  File "/usr/local/lib/python3.8/dist-packages/cmake-3.18.4.post1-py3.8-linux-x86_64.egg/cmake/__init__.py", line 46, in cmake
    raise SystemExit(_program('cmake', sys.argv[1:]))
  File "/usr/local/lib/python3.8/dist-packages/cmake-3.18.4.post1-py3.8-linux-x86_64.egg/cmake/__init__.py", line 42, in _program
    return subprocess.call([os.path.join(CMAKE_BIN_DIR, name)] + args)
  File "/usr/lib/python3.8/subprocess.py", line 340, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.8/dist-packages/cmake-3.18.4.post1-py3.8-linux-x86_64.egg/cmake/data/bin/cmake'

错误截图

答案1

在这里以普通用户和 root 用户身份从 Ubuntu 源安装。

zeus@zeus-H370M:~$ which cmake
zeus@zeus-H370M:~$
zeus@zeus-H370M:~$ su
Password: 

root@zeus-H370M:/home/zeus# apt install cmake
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
binutils binutils-common binutils-x86-64-linux-gnu cmake-data gcc gcc-9 libasan5 libatomic1
libbinutils libc-dev-bin libc6-dev libcrypt-dev libctf-nobfd0 libctf0 libgcc-9-dev libitm1
libjsoncpp1 liblsan0 libquadmath0 librhash0 libtsan0 libubsan1 linux-libc-dev make manpages-dev
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
root@zeus-H370M:/home/zeus# which cmake
/usr/bin/cmake
root@zeus-H370M:/home/zeus# cmake --version
cmake version 3.16.3

CMake suite maintained and supported by Kitware (kitware.com/cmake).
zeus@zeus-H370M:~$ cmake --version
cmake version 3.16.3

CMake suite maintained and supported by Kitware (kitware.com/cmake).

我建议从 Ubuntu 源重新安装。

root@zeus-H370M:/home/zeus# cat /etc/os-release |grep PRETTY
PRETTY_NAME="Ubuntu 20.04.2 LTS"

相关内容