本文介绍了在 Ubuntu 18.04 中使 python 模块适用于不同的用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
限时送ChatGPT账号..我的 ubuntu 中有两个用户:anubhav 和 ggc_user.
I have two users in my ubuntu : anubhav and ggc_user.
我使用 pip 安装了一个 python 模块 dlr.当我切换到用户 anubhav 并导入 dlr 时,我得到了预期的输出:
I installed a python module dlr using pip. When I switch to user anubhav and import dlr, I get expected output:
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_user 时,我在导入 dlr 时出现错误:
But when i switch to ggc_user using sudo -u ggc_user
, I get an error when I import 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)
如何使模块对两个用户都有效?
How to make the module work for both users?
推荐答案
你可以试试 --system
arg
sudo python3.7 -m pip install X --system
这篇关于在 Ubuntu 18.04 中使 python 模块适用于不同的用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论