为什么同一个服务器的不同账户编译会报错?

Web、Mail、Ftp、DNS、Proxy、VPN、Samba、LDAP 等基础网络服务
回复
yhm2046
帖子: 70
注册时间: 2008-11-20 19:20

为什么同一个服务器的不同账户编译会报错?

#1

帖子 yhm2046 » 2022-07-25 15:24

代码: 全选

OS:ubuntu16.04

同一个服务器,我的账户是user1,同事是user2
我使用python2.7单编译mm命令时候报错:

Traceback (most recent call last):
  File "/usr/lib/python3.6/dbm/gnu.py", line 4, in <module>
    from _gdbm import *
ModuleNotFoundError: No module named '_gdbm'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 7, in <module>
    import dbm.gnu as gdbm
  File "/usr/lib/python3.6/dbm/gnu.py", line 6, in <module>
    raise ImportError(str(msg) + ', please install the python3-gdbm package')
ImportError: No module named '_gdbm', please install the python3-gdbm package

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/command-not-found", line 27, in <module>
    from CommandNotFound.util import crash_guard
  File "/usr/lib/python3/dist-packages/CommandNotFound/__init__.py", line 3, in <module>
    from CommandNotFound.CommandNotFound import CommandNotFound
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 9, in <module>
    import gdbm
ModuleNotFoundError: No module named 'gdbm'


切换python3.x也是一样
sudo update-alternatives --config python

There are 2 choices for the alternative python (providing /usr/bin/python).

  Selection    Path              Priority   Status
------------------------------------------------------------
  0            /usr/bin/python2   150       auto mode
* 1            /usr/bin/python2   150       manual mode
  2            /usr/bin/python3   100       manual mode

Press <enter> to keep the current choice[*], or type selection number:
onlylove
论坛版主
帖子: 5231
注册时间: 2007-01-14 16:23

Re: 为什么同一个服务器的不同账户编译会报错?

#2

帖子 onlylove » 2022-07-25 22:11

因为不一样的用户,用户环境不一样啊
头像
astolia
论坛版主
帖子: 6451
注册时间: 2008-09-18 13:11

Re: 为什么同一个服务器的不同账户编译会报错?

#3

帖子 astolia » 2022-07-25 23:21

从报错来看,你这是找不到gdbm模块。正常的解决方法如提示所说,需要安装python3-gdbm包。
到这一步就有两个选择了
1、sudo apt install python3-gdbm
2、pip install python3-gdbm
用方法1安装的python3-gdbm包会放到/usr/share,所有用户都能访问到
而用方法2安装的python3-gdbm包,默认会放到~/.local/share下面,只有安装用户能访问到,其他用户仍然找不到
回复