Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

问题修复 #1956

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

问题修复 #1956

wants to merge 1 commit into from

Conversation

superlovelace
Copy link

修复Windows Server系统下,项目启动找不到(translate.factory)模块的问题。

版本:1.6.0

前置原因:在win10系统下可以正常启动,迁移到Windows Server系统后,启动报错:ModuleNotFoundError: No module named 'translate.factory'。

详细堆栈信息:
Traceback (most recent call last):
File "app.py", line 8, in
from channel import channel_factory
File "D:\chatgpt-on-wechat\channel\channel_factory.py", line 5, in
from .channel import Channel
File "D:\chatgpt-on-wechat\channel\channel.py", line 5, in
from bridge.bridge import Bridge
File "D:\chatgpt-on-wechat\bridge\bridge.py", line 11, in
from translate.factory import create_translator
ModuleNotFoundError: No module named 'translate.factory'

已确认依赖均已下载的情况下,根据错误提示,排查代码找到原因:bridge文件导入的translate.factory模块在文件的上一级目录下,所以在同级目录下找不到此类文件。

解决方案已应用:在目标文件内添加上一级搜索路径。

@6vision
Copy link
Collaborator

6vision commented May 12, 2024

应该不是目录的问题哈,
from translate.factory import create_translator
这个是从根目录的translate文件夹下的factory.py文件导入create_translator,

@superlovelace
Copy link
Author

个人实践遇到的问题,也按照文档看了,常见问题中说是请确认依赖都已安装,我都安装了,还是这样。事实确实是我加上这段代码就能正常启动了。(在Windows Server系统上)

@6vision
Copy link
Collaborator

6vision commented May 12, 2024

个人实践遇到的问题,也按照文档看了,常见问题中说是请确认依赖都已安装,我都安装了,还是这样。事实确实是我加上这段代码就能正常启动了。(在Windows Server系统上)

目前看应该是个例问题,增加这几行代码处理有点暴力,会对其他平台部署有影响嘛

@superlovelace
Copy link
Author

个人实践遇到的问题,也按照文档看了,常见问题中说是请确认依赖都已安装,我都安装了,还是这样。事实确实是我加上这段代码就能正常启动了。(在Windows Server系统上)

目前看应该是个例问题,增加这几行代码处理有点暴力,会对其他平台部署有影响嘛

此问题我在Windows Server 2016系统下反复测试过,加上此段代码就能正常运行,去掉就又报这个错误。win10家庭版系统因为本来就能运行,所以也启动测试了,没问题。其他平台尚不清楚,因为我目前只用在这两个系统上,大佬可以在其他平台启动测试一下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants