在一个AWS Lambda函数的virtualenv中通过pip安装模块没有错误消息

2024-03-29 11:07:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试启动一个Lambda服务器来启动其他Lambda服务器。为此,我需要在部署服务器中安装每个服务器所需的模块。这是很困难的,因为Lambda服务器非常裸,它没有pip、virtualenv或sudo,而且它提供的权限也很少。到目前为止,我已经成功地上传了一个virtualenv目录,并用subprocess.check_输出安装模块。但是,有些模块(特别是pandas、numpy和psycopg2)只是拒绝安装,退出状态为1,没有其他信息。下面是一个成功安装然后又不成功的示例:

Installing module: requests
The directory '/home/sbx_user1051/.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.
The directory '/home/sbx_user1051/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting requests
  Downloading requests-2.9.1-py2.py3-none-any.whl (501kB)
Installing collected packages: requests
Successfully installed requests-2.9.1
You are using pip version 8.0.0, however version 8.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Installing module: numpy
Command '['/tmp/lambdaTools/venv/bin/pip install numpy']' returned non-zero exit status 1: CalledProcessError
Traceback (most recent call last):
  File "/var/task/lambdaTools.py", line 39, in lambdaTools_handler
    return operations[operation](event)
  File "/var/task/lambdaTools.py", line 31, in <lambda>
    x.get('python_project'),
  File "/var/task/lambdaTools.py", line 83, in createFunction
    print(subprocess.check_output([local_path+'venv/bin/pip install '+module],shell=True,stderr=subprocess.STDOUT))
  File "/usr/lib64/python2.7/subprocess.py", line 573, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
CalledProcessError: Command '['/tmp/lambdaTools/venv/bin/pip install numpy']' returned non-zero exit status 1

这来自于密码

^{pr2}$

所以有两件事:

为什么有人能帮我解决安装失败的问题? 如果没有,我是否可以找到一种更有用的错误消息? 谢谢。在


Tags: installpipandthepynumpy服务器check