gpt4 book ai didi

python - 类型错误 : 'module' object is not callable when running pip3 with sudo on CentOS 7

转载 作者:行者123 更新时间:2023-12-04 19:41:36 29 4
gpt4 key购买 nike

如果我用 sudo 运行 pip3,它会给出以下错误消息:

[idwwwoqq808@centos7 ~]$ sudo pip3 -V
Traceback (most recent call last):
File "/bin/pip3", line 16, in <module>
sys.exit(main())
TypeError: 'module' object is not callable

但是,如果我以普通用户身份运行 pip3,它就可以正常工作:
[idwwwoqq808@centos7 ~]$ pip3 -V
pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)

我已尝试使用 pip3 install --upgrade 为所有用户升级 pip3但它只是不起作用。我怎么解决这个问题?

我问这个是因为我想安装一个包,并且由于regualr pip3 无权访问/usr 目录,该过程将因错误而停止。

pip3的源码如下:
#!/usr/bin/python3

# -*- coding: utf-8 -*-
import re
import sys

try:
from pip import main
except ImportError:
# user has most probably upgraded pip in their home
# so let them run it anyway until ~/.local/bin makes it in front of the PATH
from pip._internal import main

if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())

最佳答案

我已经使用“--User”选项成功安装了该软件包。感谢大家。

关于python - 类型错误 : 'module' object is not callable when running pip3 with sudo on CentOS 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59024296/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com