我试图找到一个临时目录,但当我试图使用目录
tempfile.gettempdir()
Run Code Online (Sandbox Code Playgroud)
它给了我错误
File "/usr/lib/python2.6/tempfile.py", line 254, in gettempdir
tempdir = _get_default_tempdir()
File "/usr/lib/python2.6/tempfile.py", line 201, in _get_default_tempdir
("No usable temporary directory found in %s" % dirlist))
IOError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/home/openerp/openerp-server']
Run Code Online (Sandbox Code Playgroud)
该目录的权限由root拥有777.
Atu*_*ind 66
这种错误发生在两种情况下
要检查空间(磁盘使用情况),只需在终端上运行命令即可
df -h
Run Code Online (Sandbox Code Playgroud)
将在unix上列出磁盘使用情况并获取输出
Filesystem Size Used Avail Use% Mounted on
/dev/sda5 28G 15G 12G 58% /
Run Code Online (Sandbox Code Playgroud)
如果root(安装在/上)使用率为100%.
您需要清理tmp目录或重新启动计算机或在根目录上留出一些空间.
小智 11
如果inode已满,也会出现问题。
你可以输入 df -i
# df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
udev 253841 322 253519 1% /dev
tmpfs 255838 430 255408 1% /run
/dev/xvda1 5120000 5120000 0 100% /
tmpfs 255838 1 255837 1% /dev/shm
tmpfs 255838 7 255831 1% /run/lock
tmpfs 255838 16 255822 1% /sys/fs/cgroup
tmpfs 255838 4 255834 1% /run/user/1000
Run Code Online (Sandbox Code Playgroud)
当 / 上没有空格时,我遇到了同样的问题。
问题:
文件“/usr/lib64/python2.6/tempfile.py”,第 201 行,在 _get_default_tempdir(“在 %s 中找不到可用的临时目录” % dirlist)) IOError: [Errno 2] 在 ['/tmp', '/var/tmp', '/usr/tmp', '/'] 中找不到可用的临时目录 [失败]
[root@master Hue]# df -h
已使用的文件系统大小 可用 使用% 安装于
/dev/mapper/vg_master-lv_root
Run Code Online (Sandbox Code Playgroud)35G 34G 0 100% /tmpfs
7.8G 72K 7.8G 1% /dev/shm/dev/sda1
477M 34M 418M 8% /boot
当我清理出一些空间后,它对我来说效果很好。
[root@master log]# 服务hue启动
起始色调:[确定]
[root@master日志]#
肯定是磁盘空间问题,
在终端上,键入df -h
您应该看到如下所示的输出(注意其中一个文件系统上的 100%)
$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 992M 0 992M 0% /dev
tmpfs 200M 21M 179M 11% /run
/dev/xvda1 7.8G 7.8G 0 100% /
tmpfs 1000M 0 1000M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 1000M 0 1000M 0% /sys/fs/cgroup
tmpfs 200M 0 200M 0% /run/user/997
tmpfs 200M 0 200M 0% /run/user/1042
Run Code Online (Sandbox Code Playgroud)
在这种情况下,您需要通过删除路径根目录上的文件、工件文件夹等来腾出空间/
在Docker中运行python脚本时遇到了同样的问题。以下命令为我修复了该问题:
docker rmi $(docker images --quiet --filter "dangling=true")
Run Code Online (Sandbox Code Playgroud)
小智 5
我在使用 Python 映像和 Gunicorn 作为入口点的 Kubernetes 部署中遇到了这个问题。我错误地在容器的 K8s 配置中设置了以下内容:
securityContext:
readOnlyRootFilesystem: true
Run Code Online (Sandbox Code Playgroud)
将其设置为false或删除它(默认为false),为我解决了这个问题。