当我尝试升级awsli:pip install awscli --upgrade时,出现以下错误: 追溯(最近一次通话):
File "/usr/local/bin/pip", line 7, in <module>
from pip._internal import main
ImportError: No module named _internal
按照Stackoverflow上的说明进行操作:pip: no module named _internal 然后出现以下错误:
python2.7 get-pip.py --user --force-reinstall
Collecting pip
Using cached https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl
botocore 1.9.22 requires docutils>=0.10, which is not installed.
awscli 1.14.69 requires colorama<=0.3.7,>=0.2.5, which is not installed.
awscli 1.14.69 requires docutils>=0.10, which is not installed.
awscli 1.14.69 requires rsa<=3.5.0,>=3.1.2, which is not installed.
awscli 1.14.69 requires s3transfer<0.2.0,>=0.1.12, which is not installed.
Installing collected packages: pip
Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/home/porter/.local/lib/python2.7'
Check the permissions.
You are using pip version 8.1.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
所以,总的来说,这真是一团糟。我认为升级到pip版本10.0.1不会有任何好处。
编辑: 我找到了罪魁祸首:/home/porter/.local/lib/python3.5。在此文件夹中,有pip询问的站点程序包:colorama,docutils,rsa,s3等。
现在该怎么办? awscli安装在以下位置: /usr/local/lib/python2.7/dist-packages/awscli
,但其依赖项安装在: /home/porter/.local/lib/python2.7 /
因此,即使更改权限后,升级awscli也不起作用。 也许最好一起卸载awscli?但是如何?
答案 0 :(得分:0)
看来您的主目录中有不属于您的文件。这是过去某个时候不正确使用sudo命令的常见结果。使用以下命令查找这些文件:
find $HOME -not -user $USER -exec ls -lad {} \;
并使用chown命令将所有权更改回给您。
答案 1 :(得分:0)
我完成了。不过,它需要一些步骤。
1.我删除了/home/porter/.local/lib/python2.7/
中的站点包
2.然后,我使用以下命令删除了awscli:
sudo python -m pip卸载awscli
我不得不使用python -m命令。否则我会遇到上述错误:
File "/usr/local/bin/pip", line 7, in <module>
from pip._internal import main
ImportError: No module named _internal