步骤:
//创建了虚拟环境
python3 venv -m venv
//激活虚拟环境
.\venv\Scripts\activate
//在虚拟环境中安装后端依赖
poetry install
// 启动后端服务
python3 main.py start
以下是 我的终端报错信息:
In a future version of Poetry this warning will become an error!
(venv) PS D:\work\haocang\demo\MaxKB> python main.py start
Building prefix dict from the default dictionary …
DEBUG:jieba:Building prefix dict from the default dictionary …
Loading model from cache C:\Users\shoub\AppData\Local\Temp\jieba.cache
DEBUG:jieba:Loading model from cache C:\Users\shoub\AppData\Local\Temp\jieba.cache
Loading model cost 0.443 seconds.
DEBUG:jieba:Loading model cost 0.443 seconds.
Prefix dict has been built successfully.
DEBUG:jieba:Prefix dict has been built successfully.
Traceback (most recent call last):
File “D:\work\haocang\demo\MaxKB\main.py”, line 75, in
start_services()
File “D:\work\haocang\demo\MaxKB\main.py”, line 46, in start_services
management.call_command(‘migrate’)
File “D:\work\haocang\demo\MaxKB\venv\Lib\site-packages\django\core\management_init_.py”, line 198, in call_command
return command.execute(*args, **defaults)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “D:\work\haocang\demo\MaxKB\venv\Lib\site-packages\django\core\management\base.py”, line 448, in execute
output = self.handle(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “D:\work\haocang\demo\MaxKB\venv\Lib\site-packages\django\core\management\base.py”, line 96, in wrapped
res = handle_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “D:\work\haocang\demo\MaxKB\venv\Lib\site-packages\django\core\management\commands\migrate.py”, line 114, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “D:\work\haocang\demo\MaxKB\venv\Lib\site-packages\django\db\migrations\executor.py”, line 18, in init
self.loader = MigrationLoader(self.connection)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “D:\work\haocang\demo\MaxKB\venv\Lib\site-packages\django\db\migrations\loader.py”, line 58, in init
self.build_graph()
File “D:\work\haocang\demo\MaxKB\venv\Lib\site-packages\django\db\migrations\loader.py”, line 235, in build_graph
self.applied_migrations = recorder.applied_migrations()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “D:\work\haocang\demo\MaxKB\venv\Lib\site-packages\django\db\migrations\recorder.py”, line 81, in applied_migrations
if self.has_table():
^^^^^^^^^^^^^^^^
File “D:\work\haocang\demo\MaxKB\venv\Lib\site-packages\django\db\migrations\recorder.py”, line 57, in has_table
with self.connection.cursor() as cursor:
^^^^^^^^^^^^^^^^^^^^^^^^
File “D:\work\haocang\demo\MaxKB\venv\Lib\site-packages\django\utils\asyncio.py”, line 26, in inner
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File “D:\work\haocang\demo\MaxKB\venv\Lib\site-packages\django\db\backends\base\base.py”, line 323, in cursor
return self._cursor()
^^^^^^^^^^^^^^
File “D:\work\haocang\demo\MaxKB\venv\Lib\site-packages\django\db\backends\base\base.py”, line 299, in cursor
self.ensure_connection()
File “D:\work\haocang\demo\MaxKB\venv\Lib\site-packages\django\utils\asyncio.py”, line 26, in inner
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File “D:\work\haocang\demo\MaxKB\venv\Lib\site-packages\django\db\backends\base\base.py”, line 282, in ensure_connection
self.connect()
File “D:\work\haocang\demo\MaxKB\venv\Lib\site-packages\django\utils\asyncio.py”, line 26, in inner
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File “D:\work\haocang\demo\MaxKB\venv\Lib\site-packages\django\db\backends\base\base.py”, line 263, in connect
self.connection = self.get_new_connection(conn_params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “D:\work\haocang\demo\MaxKB\venv\Lib\site-packages\django\utils\asyncio.py”, line 26, in inner
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File “D:\work\haocang\demo\MaxKB\venv\Lib\site-packages\django\db\backends\postgresql\base.py”, line 215, in get_new_connection
connection = Database.connect(**conn_params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\work\haocang\demo\MaxKB\venv\Lib\site-packages\psycopg2_init.py", line 122, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xd6 in position 61: invalid continuation byte