OSError:[Errno 13] 权限被拒绝:'/usr/local/lib/python2.7/dist-packages/pelican-3.6.3.dist-info'

OSError:[Errno 13] 权限被拒绝:'/usr/local/lib/python2.7/dist-packages/pelican-3.6.3.dist-info'

我跑 pip install pelican markdown

我收到此错误信息:

Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 283, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1436, in install
    requirement.install(install_options, global_options, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 672, in install
    self.move_wheel_files(self.source_dir, root=root)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 902, in move_wheel_files
    pycompile=self.pycompile,
  File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 206, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 193, in clobber
    os.makedirs(destsubdir)
  File "/usr/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/pelican-3.6.3.dist-info'

Storing debug log for failure in /home/begueradj/.pip/pip.log

如何解决这个问题?

答案1

虽然可以将其作为全局站点包安装,但我认为最好研究一下 python 虚拟环境。

1.使用虚拟环境:

使用 sudo 安装 virtualenv

apt-get install python-virtualenv

然后你可以创建一个虚拟环境:

virtualenv pelican

并激活它:

. pelican/bin/activate

(注意开头的点+空格)。然后你可以运行

pip install pelican markdown

将其安装在这个虚拟环境中。完成此操作后,您可以运行

deactivate

停用该环境。当您想再次处理项目时,您必须再次激活该环境。

2. 虚拟环境包装器

virtualenvwrapper 是一个可以更轻松地管理多个虚拟环境的工具。您可以通过输入以下命令来安装它:

sudo apt-get install virtualenvwrapper

然后使用创建虚拟环境

mkvirtualenv pelican

并安装你的软件包

pip install pelican markdown

然后可以使用以下命令停用此环境

deactivate

当您想再次使用此环境时,请运行:

workon pelican

作为全局站点包安装

如果你坚持将其作为全局站点包安装,请运行

sudo pip install pelican markdown

相关内容