【发布时间】:2019-01-31 09:43:36
【问题描述】:
我的 Google Cloud Functions (GCF) 功能需要 2 个软件包才能正常工作。我通常会在 Ubuntu 上使用以下命令安装它们:
apt-get -y install firefox xvfb
但是,无论如何,我不知道要打包我的函数,这将指导 GCF 在运行我的代码之前下载这些包。
我尝试使用 subprocess.call() 从我的 Python 函数中安装它们。
这里有一些代码:
try:
print(subprocess.check_output("apt-get -y install firefox", shell=True, stderr=subprocess.STDOUT))
except subprocess.CalledProcessError as e:
print("Ping stdout output:\n", e.output)
try:
print(subprocess.check_output("apt-get -y install xvfb", shell=True, stderr=subprocess.STDOUT))
except subprocess.CalledProcessError as e:
print("Ping stdout output:\n", e.output)
很遗憾,这不起作用。我收到以下错误:
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
libcanberra0 libdbusmenu-gtk3-4 libstartup-notification0 libtdb1
libxcb-util1 sound-theme-freedesktop xul-ext-ubufox
Suggested packages:\n fonts-lyx libcanberra-gtk0 libcanberra-pulse
The following NEW packages will be installed: firefox
libcanberra0 libdbusmenu-gtk3-4 libstartup-notification0 libtdb1
libxcb-util1 sound-theme-freedesktop xul-ext-ubufox
0 upgraded, 8 newly installed, 0 to remove and 5 not upgraded.
Need to get 44.5 MB of archives.
After this operation, 170 MB of additional disk space will be used.
W: Not using locking for read only lock file /var/lib/dpkg/lock
W: chown to _apt:root of directory /var/cache/apt/archives/partial failed - SetupAPTPartialDirectory (30: Read-only file system)
W: chmod 0700 of directory /var/cache/apt/archives/partial failed - SetupAPTPartialDirectory (1: Operation not permitted)
W: chown to _apt:root of directory /var/lib/apt/lists/auxfiles failed - SetupAPTPartialDirectory (30: Read-only file system)
W: chmod 0700 of directory /var/lib/apt/lists/auxfiles failed - SetupAPTPartialDirectory (1: Operation not permitted)
W: Not using locking for read only lock file /var/cache/apt/archives/lock
E: Couldn't determine free space in /var/cache/apt/archives/ - statvfs (38: Function not implemented)
如何解决此错误以从我的 python 代码中下载包?有没有其他(更简单/更清洁)的方法来实现我想要做的事情?
谢谢!
【问题讨论】:
标签: python-3.x firefox google-cloud-platform google-cloud-functions xvfb