在 Ubuntu 18.04 中使 python 模块适用于不同的用户

编程入门 行业动态 更新时间:2024-10-27 06:24:23
本文介绍了在 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:关键词]

本文发布于:2023-04-29 07:33:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1186772.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:适用于   模块   用户   Ubuntu   python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!