Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用谷歌云功能时,有没有办法在/tmp中创建文件夹?_Python_Google Cloud Platform_Google Cloud Functions - Fatal编程技术网

Python 使用谷歌云功能时,有没有办法在/tmp中创建文件夹?

Python 使用谷歌云功能时,有没有办法在/tmp中创建文件夹?,python,google-cloud-platform,google-cloud-functions,Python,Google Cloud Platform,Google Cloud Functions,我需要在谷歌云功能的/tmp文件夹中创建两个文件夹。我使用的是一个库,它要求文件采用这种格式(它们不能全部采用/tmp) 我尝试了这个-os.makedirs('tmp/test'),但出现了以下错误: Function failed on loading user code. Error message: [Errno 30] Read-only file system: 'tmp' Detailed stack trace: Traceback (most recent call last)

我需要在谷歌云功能的
/tmp
文件夹中创建两个文件夹。我使用的是一个库,它要求文件采用这种格式(它们不能全部采用
/tmp

我尝试了这个-
os.makedirs('tmp/test')
,但出现了以下错误:

Function failed on loading user code. Error message: [Errno 30] Read-only file system: 'tmp'
Detailed stack trace:
Traceback (most recent call last):
File "/env/local/lib/python3.7/site-packages/google/cloud/functions/worker_v1.py", line 315, in check_or_load_user_function
_function_handler.load_user_function()
File "/env/local/lib/python3.7/site-packages/google/cloud/functions/worker_v1.py", line 190, in load_user_function
spec.loader.exec_module(main_module)
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/user_code/main.py", line 3, in <module>
os.makedirs('tmp/test')
File "/env/lib/python3.7/os.py", line 213, in makedirs
makedirs(head, exist_ok=exist_ok)
File "/env/lib/python3.7/os.py", line 223, in makedirs
mkdir(name, mode)
OSError: [Errno 30] Read-only file system: 'tmp'
函数在加载用户代码时失败。错误消息:[Errno 30]只读文件系统:“tmp”
详细堆栈跟踪:
回溯(最近一次呼叫最后一次):
文件“/env/local/lib/python3.7/site packages/google/cloud/functions/worker\u v1.py”,第315行,在check\u或\u load\u user\u函数中
_函数\处理程序。加载\用户\函数()
文件“/env/local/lib/python3.7/site packages/google/cloud/functions/worker\u v1.py”,第190行,在load\u user\u函数中
规格加载器执行模块(主模块)
exec_模块中第728行的文件“”
文件“”,第219行,在“调用”中,删除了“帧”
文件“/user\u code/main.py”,第3行,在
os.makedirs('tmp/test')
makedirs中的文件“/env/lib/python3.7/os.py”,第213行
makedirs(head,exist\u ok=exist\u ok)
makedirs中的文件“/env/lib/python3.7/os.py”,第223行
mkdir(名称、模式)
OSError:[Errno 30]只读文件系统:“tmp”
有什么办法可以解决这个问题吗?

使用
os.makedirs('tmp/test')
将尝试在
/user\u code/tmp/test
创建一个不可写的目录


您需要使用一个前导斜杠来确保在
/tmp/test
处创建目录,它是文件系统中唯一可写的部分。

sudo chmod-R 766/tmp
您可能希望在
tmp
前面加上
/
前缀,以确保它尝试在根
/tmp
下而不是在当前目录下创建子目录。所以
os.makedirs('/tmp/test')
.Hi@Shawn你有没有尝试一下Frank的评论?