尝试使用 ansible 在 vi​​rtualenv 内安装时权限被拒绝

2024-03-13

我的 ansible 剧本中有这个剧本

- name: Setup virtualenv
  pip: 
    requirements="/vagrant/webapp/requirements/{{ requirements_filename }}" 
    virtualenv="$HOME/.envs/{{ project_name }}"

但是,我收到了权限被拒绝的错误。看起来 ansible 正在尝试将软件包安装到系统路径中,而不是安装到 virtualenv 中。

这是完整的回溯:

TASK: [deploy | Setup virtualenv] ********************************************* 
failed: [default] => {"cmd": "/usr/bin/pip install -r /vagrant/webapp/requirements/dev.txt", "failed": true}
msg: stdout: New python executable in /home/vagrant/.envs/venv/bin/python
Installing setuptools, pip...done.
Downloading/unpacking django>=1.8 (from -r /vagrant/webapp/requirements/requirements.txt (line 3))
Requirement already satisfied (use --upgrade to upgrade): wsgiref>=0.1.2 in /usr/lib/python2.7 (from -r /vagrant/webapp/requirements/requirements.txt (line 4))
Downloading/unpacking django-allauth>=0.19.1 (from -r /vagrant/webapp/requirements/requirements.txt (line 5))
  Running setup.py (path:/tmp/pip_build_vagrant/django-allauth/setup.py) egg_info for package django-allauth

Downloading/unpacking psycopg2>=2.6 (from -r /vagrant/webapp/requirements/requirements.txt (line 6))
  Running setup.py (path:/tmp/pip_build_vagrant/psycopg2/setup.py) egg_info for package psycopg2

Downloading/unpacking django-currencies>=0.3.3 (from -r /vagrant/webapp/requirements/requirements.txt (line 7))
  Downloading django-currencies-0.3.3.tar.gz
  Running setup.py (path:/tmp/pip_build_vagrant/django-currencies/setup.py) egg_info for package django-currencies

Downloading/unpacking django-countries>=3.2 (from -r /vagrant/webapp/requirements/requirements.txt (line 8))
  Running setup.py (path:/tmp/pip_build_vagrant/django-countries/setup.py) egg_info for package django-countries

Downloading/unpacking stripe>=1.22.1 (from -r /vagrant/webapp/requirements/requirements.txt (line 9))
  Running setup.py (path:/tmp/pip_build_vagrant/stripe/setup.py) egg_info for package stripe

Downloading/unpacking pillow>=2.8.0 (from -r /vagrant/webapp/requirements/requirements.txt (line 10))
  Running setup.py (path:/tmp/pip_build_vagrant/pillow/setup.py) egg_info for package pillow
    Single threaded build, not installing mp_compile: 1 processes

    warning: no files found matching 'LICENSE' under directory 'docs'
Downloading/unpacking django-compressor>=1.4 (from -r /vagrant/webapp/requirements/requirements.txt (line 11))
Downloading/unpacking djangorestframework>=3.1.1 (from -r /vagrant/webapp/requirements/requirements.txt (line 12))
Downloading/unpacking django-filter>=0.9.2 (from -r /vagrant/webapp/requirements/requirements.txt (line 13))
  Downloading django_filter-0.9.2-py2.py3-none-any.whl
Obtaining formtools from git+https://github.com/django/django-formtools.git#egg=formtools (from -r /vagrant/webapp/requirements/requirements.txt (line 14))
  Cloning https://github.com/django/django-formtools.git to ./src/formtools
  Running setup.py (path:/tmp/src/formtools/setup.py) egg_info for package formtools

  Installing extra requirements: 'egg'
Downloading/unpacking django-widget-tweaks>=1.3 (from -r /vagrant/webapp/requirements/requirements.txt (line 15))
  Downloading django-widget-tweaks-1.3.tar.gz
  Running setup.py (path:/tmp/pip_build_vagrant/django-widget-tweaks/setup.py) egg_info for package django-widget-tweaks

Downloading/unpacking django-braces>=1.4.0 (from -r /vagrant/webapp/requirements/requirements.txt (line 16))
  Downloading django_braces-1.4.0-py2.py3-none-any.whl
Downloading/unpacking django-debug-toolbar>=1.3.0 (from -r /vagrant/webapp/requirements/dev.txt (line 4))
Downloading/unpacking python-openid>=2.2.5 (from django-allauth>=0.19.1->-r /vagrant/webapp/requirements/requirements.txt (line 5))
  Running setup.py (path:/tmp/pip_build_vagrant/python-openid/setup.py) egg_info for package python-openid

    warning: no files found matching 'CHANGELOG'
    warning: no files found matching '*.css' under directory 'doc'
    warning: no files found matching '*.html' under directory 'doc'
Downloading/unpacking requests-oauthlib>=0.3.0 (from django-allauth>=0.19.1->-r /vagrant/webapp/requirements/requirements.txt (line 5))
  Downloading requests_oauthlib-0.4.2-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): requests>=1.0.3 in /usr/lib/python2.7/dist-packages (from django-allauth>=0.19.1->-r /vagrant/webapp/requirements/requirements.txt (line 5))
Downloading/unpacking django-appconf>=0.4 (from django-compressor>=1.4->-r /vagrant/webapp/requirements/requirements.txt (line 11))
  Downloading django_appconf-1.0.1-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): six in /usr/local/lib/python2.7/dist-packages (from django-braces>=1.4.0->-r /vagrant/webapp/requirements/requirements.txt (line 16))
Downloading/unpacking sqlparse (from django-debug-toolbar>=1.3.0->-r /vagrant/webapp/requirements/dev.txt (line 4))
  Running setup.py (path:/tmp/pip_build_vagrant/sqlparse/setup.py) egg_info for package sqlparse

Downloading/unpacking oauthlib>=0.6.2 (from requests-oauthlib>=0.3.0->django-allauth>=0.19.1->-r /vagrant/webapp/requirements/requirements.txt (line 5))
  Running setup.py (path:/tmp/pip_build_vagrant/oauthlib/setup.py) egg_info for package oauthlib

Installing collected packages: django, django-allauth, psycopg2, django-currencies, django-countries, stripe, pillow, django-compressor, djangorestframework, django-filter, formtools, django-widget-tweaks, django-braces, django-debug-toolbar, python-openid, requests-oauthlib, django-appconf, sqlparse, oauthlib
Cleaning up...
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 1435, in install
    requirement.install(install_options, global_options, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 671, in install
    self.move_wheel_files(self.source_dir, root=root)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 901, 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/Django-1.8.dist-info'

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


FATAL: all hosts have already failed -- aborting

我通过明确设置路径而不是使用$HOME多变的。

- name: Setup virtualenv
  pip:
    virtualenv="/home/vagrant/.envs/{{ project_name }}"
    requirements="/vagrant/webapp/requirements/{{ requirements_filename }}"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

尝试使用 ansible 在 vi​​rtualenv 内安装时权限被拒绝 的相关文章

随机推荐

  • 在 PHP 中获取数组的最后一个元素而不更改数组? [复制]

    这个问题在这里已经有答案了 array pop 将其从数组中删除 end 改变内部指针 唯一的方法真的像这样 my array array pop array keys my array 这有效 list end array slice a
  • 如何检查 window.external 上是否存在函数

    如何检查 window external 上是否存在函数 我正在从 javascript 调用 C 代码 并且想检查 C 对象中是否存在方法 我找到了路 只需使用 in 运算符 如下所示 if FunctionName in window
  • 元组的串联

    普通文本 我在 python 3 2 1 上编码时遇到一些问题 实际上我正在参加有关 python 2 5 的在线讲座 这是代码 x 100 divisors for i in range 1 x if x i 0 divisors div
  • 在 bash shell 中打印星号(“*”)

    a 5 echo aMin bash etc init d ckDskCheck sh 当我尝试运行以下代码时 它会正确显示 5 bash etc init d ckDskCheck sh 但是 当我尝试使用以下代码将结果分配给变量并将其打
  • 快速使用未解析的标识符“UIApplicationStateInactive”

    在我处理推送通知的 Swift 代码中 我有这一行 if application applicationState UIApplicationStateInactive application applicationState UIAppl
  • 如何在sqlite android中插入多行

    我有一种方法可以将值插入到sqlite在一个班级里 在主要活动中 我正在解析 json 值并尝试将这些值插入到sqlite在循环中 因为我必须插入不止一行 但只有一行被添加到数据库中 添加多行的方法如下 public void addSes
  • 如何访问SetDefaultContentHeaders中的底层对象?

    我有一个 Web api 我在其中返回一个对象 当我使用接受标头 image jpg 时 我想要该对象的图像表示形式 但我想根据我返回的对象设置文件名 我已经实施了一个BufferedMediaTypeFormatter并认为我应该在方法中
  • 如何在 Windows 中使用本地路径访问 Subversion 存储库?

    我安装了 CollabNet Subversion 服务器和客户端 运行附带的 Apache 从服务器上的命令行 我可以使用类似的路径轻松访问存储库 http server port svn repository 但我无法使用它在磁盘上的实
  • 类似 git 界面的最佳方法

    我正在编写一个小型命令行待办事项应用程序 它具有类似于 git 的通用界面 它可以执行多项任务 add list complete 所有这些都应该可以通过todo
  • docker容器主机名顺序号

    在 docker swarm 中存在副本 规模的情况下 是否有任何选项可以让主机名 容器名具有一些序列号 version 3 services serA image someimage1 hostname serA serB image s
  • 在 C# 中将字符串存储为 UTF8

    我在 C 中进行了大量的字符串操作 并且确实需要将字符串每个字符存储一个字节 这是因为我需要在内存中同时存储千兆字节的文本 这会导致内存不足的问题 我确信该文本永远不会包含非 ASCII 字符 因此就我的目的而言 System String
  • 一个类可以从类本身内部取消吗?

    例如 此代码有效吗 class abc int x y abc int x int y this x x this y y while true update public void update x y if y 0 this null
  • Python的seek函数是如何工作的?

    如果我有一些类似文件的对象并执行以下操作 F open abc r loc F tell F seek loc 10 寻求有什么作用 是从文件开头开始读取loc 10字节 或者它是否足够聪明 只备份 10 个字节 它是特定于操作系统和 li
  • 用 AJAX 调用替换多少内容就太多了?

    我在尝试进行 AJAX 开发时遇到了一个常见问题 在可能的情况下 我喜欢尝试只更新现有布局中的数据 而不是布局本身 例如 采用下面的 div div Here is some content div 我会得到更新的值content 5从服务
  • 使用“read”读取密码时如何回显星号(*)?

    如果我想回显 我需要对 Bash 中的代码做什么 当用户在 using 中键入某些内容时 用 s 代替密码字符 甚至完全隐藏这些字符 read As 马克 鲁沙科夫指出 read s将抑制在提示符下键入的字符的回显 您可以利用该功能作为此脚
  • jqGrid如何使用EditUrl

    我正在使用 jqGrid 使用 jSON 数据维护 MySQL 中的数据库 我能够在网格中显示数据 但是当我尝试通过模式表单添加或编辑数据行时 我收到一条消息 未设置 URL 但是 editurl 应该包含什么 mysql插入语句 我正在使
  • 如何在 TypeScript 中使用 Node `http` 模块

    我需要用 TypeScript 和 Node js 编写一个服务器 我下载了Node https github com DefinitelyTyped DefinitelyTyped blob master node node d ts f
  • 从 Dispatcher.RunAsync() 返回一个值到后台线程

    我正在使用 Dispatcher RunAsync 从后台线程显示 MessageDialog 但我无法弄清楚如何返回结果 My code bool response false await dispatcher RunAsync Wind
  • 使用 Livewire 和 Filepond 编辑模型时处理预先存在的图像

    我有一个 Filepond 组件 非常适合将图像上传到帖子 然而 当我需要编辑帖子及其预先存在的图像时 我正在与 Filepond 作斗争 我想用 Post 模型预先存在的图像加载 Filepond 目标是允许用户在编辑 Post 模型时上
  • 尝试使用 ansible 在 vi​​rtualenv 内安装时权限被拒绝

    我的 ansible 剧本中有这个剧本 name Setup virtualenv pip requirements vagrant webapp requirements requirements filename virtualenv