python - 在本地运行服务器时出现 Django 错误 - AttributeError: 'list' object has no attribute 'read'
问题描述
尝试在 Django 的 VS Code 中运行服务器时出现以下错误。命令:python manage.py runserver 错误:
C:\DjangoServerTest\DjangoServerTest>python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\Users\subhasispanda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Users\subhasispanda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\subhasispanda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\subhasispanda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options)
File "C:\Users\subhasispanda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py", line 369, in execute
output = self.handle(*args, **options)
File "C:\Users\subhasispanda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\commands\runserver.py", line 95, in handle
self.run(**options)
File "C:\Users\subhasispanda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\commands\runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "C:\Users\subhasispanda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 601, in run_with_reloader
exit_code = restart_with_reloader()
File "C:\Users\subhasispanda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 230, in restart_with_reloader
p = subprocess.run(args, env=new_environ, close_fds=False)
File "C:\Users\subhasispanda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\run\__init__.py", line 145, in __new__
process = cls.create_process(command, stdin, cwd=cwd, env=env, shell=shell)
File "C:\Users\subhasispanda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\run\__init__.py", line 121, in create_process
shlex.split(command),
File "C:\Users\subhasispanda\AppData\Local\Programs\Python\Python37-32\lib\shlex.py", line 305, in split
return list(lex)
File "C:\Users\subhasispanda\AppData\Local\Programs\Python\Python37-32\lib\shlex.py", line 295, in __next__
token = self.get_token()
File "C:\Users\subhasispanda\AppData\Local\Programs\Python\Python37-32\lib\shlex.py", line 105, in get_token
raw = self.read_token()
File "C:\Users\subhasispanda\AppData\Local\Programs\Python\Python37-32\lib\shlex.py", line 136, in read_token
nextchar = self.instream.read(1)
AttributeError:“列表”对象没有属性“读取”
你能在这里帮忙吗?
解决方案
I too had the same issue. What i did is that i went to control panel -> search -> advanced system settings ->environment variables -> Path then cleared all paths Uninstalled python, and deleted all the python related files in the "C:\Users{user_name}\AppData\Local\Programs" directory And then downloaded the latest one and installed again. Then added the scripts folder and the python folder directory into the PATH. Then installed pip and then django. Now its woking perfectly.
In short remove all the versions of python completely and then install it again. Also clear all the unwanted "paths" in the environment variables.....
推荐阅读
- python-3.x - 机器学习研究论文的结果/比较部分说明了哪种准确性?是训练准确性还是验证准确性
- python - 如何从数据集中的列中获取特定整数,并将每个整数分成一个变量
- java - Spring Boot 实例化多个组件
- c# - C# Linq Lamba 元素计数
- iot - 安全连接到 IoT Edge 设备
- firebase - 对象中的 Flutter Firestore 查询字段
- reactjs - 这两种 react-router Route 方法之间的确切区别是什么?
- npm - 遇到错误:在 mocha 中找不到模块 'dotenv'
- java - 如何将android studio连接到influxDB
- python - 如何使这个递归函数不给我相同的列表但以不同的顺序