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 用户的主目录作为缓存。