Python pip3 的权限错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27849412/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PermissionError with pip3
提问by Meghdeep Ray
This is the error when I try to get anything with pip3 I'm not sure what to do
这是我尝试使用 pip3 获取任何内容时出现的错误我不知道该怎么做
Exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 283, in run
requirement_set.install(install_options, global_options, root=options.root_path)
File "/usr/lib/python3/dist-packages/pip/req.py", line 1435, in install
requirement.install(install_options, global_options, *args, **kwargs)
File "/usr/lib/python3/dist-packages/pip/req.py", line 671, in install
self.move_wheel_files(self.source_dir, root=root)
File "/usr/lib/python3/dist-packages/pip/req.py", line 901, in move_wheel_files
pycompile=self.pycompile,
File "/usr/lib/python3/dist-packages/pip/wheel.py", line 206, in move_wheel_files
clobber(source, lib_dir, True)
File "/usr/lib/python3/dist-packages/pip/wheel.py", line 193, in clobber
os.makedirs(destsubdir)
File "/usr/lib/python3.4/os.py", line 237, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.4/dist- packages/Django-1.7.2.dist-info'
Storing debug log for failure in /home/omega/.pip/pip.log
采纳答案by Padraic Cunningham
You need to use sudoto install globally or have permissions to write to the folder. Or as @Alasdair commented using a virtualenvis a better option.
您需要用于sudo全局安装或具有写入文件夹的权限。或者正如@Alasdair 评论的那样,使用virtualenv是更好的选择。
回答by Seenivasan
just install them using --user option which install the package only for the current user and not for all
只需使用 --user 选项安装它们,该选项仅为当前用户而不是所有用户安装软件包
pip install xxxxxx --user
回答by Atiar Talukdar
use --user at last of your install command, so that the package will be installed only for the current user, not for all.
在安装命令的最后使用 --user ,以便仅为当前用户安装包,而不是为所有用户安装。
pip install xxxxxx --user
or
或者
pip3 install xxxxxx --user
回答by Sarvagya Gupta
Just add sudobefore pip3. Like sudo pip3 install <package>
只需sudo在 pip3 之前添加。喜欢sudo pip3 install <package>
回答by Kartikeya_M
pip3 install --user <package_name>
No need to write your username in place of --user.
无需用您的用户名代替 --user。

