![我想安装一个使用 python 中的 pip 的暴力破解器,帮帮我吧!](https://linux22.com/image/898314/%E6%88%91%E6%83%B3%E5%AE%89%E8%A3%85%E4%B8%80%E4%B8%AA%E4%BD%BF%E7%94%A8%20python%20%E4%B8%AD%E7%9A%84%20pip%20%E7%9A%84%E6%9A%B4%E5%8A%9B%E7%A0%B4%E8%A7%A3%E5%99%A8%EF%BC%8C%E5%B8%AE%E5%B8%AE%E6%88%91%E5%90%A7%EF%BC%81.png)
The directory '/home/anuj/.cache/pip/http' or its parent directory is not
owned by the current user and the cache has been disabled.
Please check the permissions and owner of that directory.
If executing pip with sudo, you may want sudo's -H flag.
运行以下 Python 脚本时出现此错误:
import os
os.system("sudo apt-get install python-pip python-dev build-essential -y")
os.system("sudo apt-get install build-essential libssl-dev libffi-dev python-dev python-setuptools -y")
os.system("pip install -U selenium && sudo apt-get install firefoxdriver -y")
os.system("pip install mechanize && pip install paramiko && pip install requests && pip install xmpppy==0.5.0rc1")
os.system("pip install stem && pip install pyvirtualdisplay && apt-get install xvfb")
现在我需要安装,请帮帮我!
答案1
使用以下命令重新获得主目录中 pip 缓存文件夹的所有权:
sudo chown -R anuj: /home/anuj/.cache/pip/
此后,pip
就应该停止抱怨。
将来,不要再运行sudo pip
。如果你确实需要使用pip
为所有用户全局安装 Python 包,请改用sudo -H pip
,这样它将使用 root 用户的主目录作为缓存。