OSError:[Errno 18]无效的跨设备链接 [英] OSError: [Errno 18] Invalid cross-device link

查看:866
本文介绍了OSError:[Errno 18]无效的跨设备链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Django 1.6.5和python 2.7. 我的应用程序中具有导入功能,但出现错误:

I'm working with django 1.6.5 and python 2.7. I have import feature in my app and I get error:

OSError: [Errno 18] Invalid cross-device link

我对这部分代码有疑问:

I have problem with this part of code:

os.rename(db_temp, settings.DATABASES['bookmat']['NAME'])

设置中的代码:

'bookmat': {
    'ENGINE': 'django.db.backends.sqlite3',
    'NAME': '/my_projects/book/db/bookmat.sqlite3',
},

推荐答案

os.rename仅在源和目标位于同一文件系统上时有效.您应该改用shutil.move.

os.rename only works if source and destination are on the same file system. You should use shutil.move instead.

这篇关于OSError:[Errno 18]无效的跨设备链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆