Windows下运行Django2.x项目触发WinError123路径错误求助
本地运行开源Django项目报错问题
问题说明
- 尝试在本地计算机运行一款开源项目时触发运行报错,因不清楚该类问题的排查与解决方法,希望有相关经验的开发者能分享解决思路
- 标注的运行环境为Python 3.6、Django 2.X版本
- 从报错路径可以看到,当前程序实际关联的依赖存储路径为
C:\Python37\lib\site-packages,存在环境版本标注与实际运行不匹配的情况
完整错误堆栈
Traceback (most recent call last): File "C:/Users/Asus/Desktop/Fiverr/vulunteer/manage.py", line 37, in <module> execute_from_command_line(sys.argv) File "C:\Python37\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line utility.execute() File "C:\Python37\lib\site-packages\django\core\management\__init__.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Python37\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv self.execute(*args, **cmd_options) File "C:\Python37\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute super().execute(*args, **options) File "C:\Python37\lib\site-packages\django\core\management\base.py", line 364, in execute output = self.handle(*args, **options) File "C:\Python37\lib\site-packages\django\core\management\commands\runserver.py", line 95, in handle self.run(**options) File "C:\Python37\lib\site-packages\django\core\management\commands\runserver.py", line 102, in run autoreload.run_with_reloader(self.inner_run, **options) File "C:\Python37\lib\site-packages\django\utils\autoreload.py", line 598, in run_with_reloader start_django(reloader, main_func, *args, **kwargs) File "C:\Python37\lib\site-packages\django\utils\autoreload.py", line 583, in start_django reloader.run(django_main_thread) File "C:\Python37\lib\site-packages\django\utils\autoreload.py", line 301, in run self.run_loop() File "C:\Python37\lib\site-packages\django\utils\autoreload.py", line 307, in run_loop next(ticker) File "C:\Python37\lib\site-packages\django\utils\autoreload.py", line 347, in tick for filepath, mtime in self.snapshot_files(): File "C:\Python37\lib\site-packages\django\utils\autoreload.py", line 363, in snapshot_files for file in self.watched_files(): File "C:\Python37\lib\site-packages\django\utils\autoreload.py", line 262, in watched_files yield from iter_all_python_module_files() File "C:\Python37\lib\site-packages\django\utils\autoreload.py", line 103, in iter_all_python_module_files return iter_modules_and_files(modules, frozenset(_error_files)) File "C:\Python37\lib\site-packages\django\utils\autoreload.py", line 139, in iter_modules_and_files if not path.exists(): File "C:\Python37\lib\pathlib.py", line 1346, in exists self.stat() File "C:\Python37\lib\pathlib.py", line 1168, in stat return self._accessor.stat(self) OSError: [WinError 123] 文件名、目录名或卷标语法不正确: 'C:\\Users\\Asus\\Desktop\\Fiverr\\vulunteer\\templates\\admin:admin\\base.html' Process finished with exit code 1
报错核心特征
- 报错触发位置为Django内置自动重载的文件监听环节,程序遍历需监控的关联文件列表时,读取到路径格式非法的文件条目
- 非法路径中包含
admin:admin字段,该写法是Django反向解析路由的标准格式,被错误拼接为本地文件路径的一部分;字段中的冒号属于Windows系统路径禁止使用的特殊字符,直接触发WinError 123系统报错
内容的提问来源于stack exchange,提问作者Mohammad Nasir
相关产品推荐
相关产品推荐

