在Ubuntu 18.04中让python模块为不同的用户工作

2024-09-28 05:20:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我的ubuntu中有两个用户:anubhav和ggc_用户

我使用pip安装了一个python模块dlr。 当我切换到用户anubhav并导入dlr时,我得到了预期的输出:

anubhav@Surface-Pro-3:/usr/bin$ python3
Python 3.7.5 (default, Nov  7 2019, 10:50:52) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dlr

CALL HOME FEATURE ENABLED

但是,当我使用sudo -u ggc_user切换到ggcāU用户时,我在导入dlr时收到一个错误:

anubhav@Surface-Pro-3:/usr/bin$ sudo -u ggc_user bash
ggc_user@Surface-Pro-3:/usr/bin$ python3
Python 3.7.5 (default, Nov  7 2019, 10:50:52) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dlr
/usr/lib/python3/dist-packages/requests/__init__.py:80: RequestsDependencyWarning: urllib3 (1.26.3) or chardet (3.0.4) doesn't match a supported version!
  RequestsDependencyWarning)

如何使模块同时适用于两个用户


Tags: 模块or用户defaultbinusrsurfacenov

热门问题