BallonsTranslator
BallonsTranslator copied to clipboard
linux/mac os support
Hello!
Can you make release for linux/mac os ?
Hello
I'll build a linux excuctable for next version, however I don't have a mac so I can't provide support for mac os.
The source code should run fine on mac if python(<3.10) environment is set up:
python ballontranslator/__main__.py
Thanks!
➜ python3 ballontranslator/__main__.py
[INFO ] import_utils:<module>:50 - PyTorch version 1.11.0 available.
[INFO ] import_utils:<module>:50 - PyTorch version 1.11.0 available.
PyTorch version 1.11.0 available.
Traceback (most recent call last):
File "/Users/kota/Downloads/BallonsTranslator-master/ballontranslator/__main__.py", line 30, in <module>
main()
File "/Users/kota/Downloads/BallonsTranslator-master/ballontranslator/__main__.py", line 24, in main
ballontrans = MainWindow(app, open_dir=args.proj_dir)
File "/Users/kota/Downloads/BallonsTranslator-master/ballontranslator/ui/mainwindow.py", line 45, in __init__
self.setupUi()
File "/Users/kota/Downloads/BallonsTranslator-master/ballontranslator/ui/mainwindow.py", line 75, in setupUi
self.setMinimumWidth(screen_size.width()*0.5)
TypeError: setMinimumWidth(self, int): argument 1 has unexpected type 'float'
I will wait for the corrections for the linux version. And then I will try to build for mac os.
If you want, i can help with mac os release.
line 75: explicitly convert to int type should fix this, self.setMinimumWidth(int(screen_size.width()*0.5))
Any help would be appreciated.
line 75: explicitly convert to int type should fix this,
self.setMinimumWidth(int(screen_size.width()*0.5))
Yes, I know. On the weekend I will try to fix all the errors and build a release for the mac OS.
我也等一个macos版,需要的话可以帮忙在M1 pro上进行build,可能需要提供build的步骤
我也等一个macos版,需要的话可以帮忙在M1 pro上进行build,可能需要提供build的步骤
经提醒可以用github actions,我下礼拜试试
qt5是支持macOS的,但是我不懂Github Action的Workflow要怎么写能编译成功qt5,只会electron的workflow
qt5是支持macOS的,但是我不懂Github Action的Workflow要怎么写能编译成功qt5,只会electron的workflow
装了环境gitclone源码python ballontranslator/main.py应该就能跑,不需要pydensecrf,可能会有些类型错误不过改起来也简单

brew install mecab
后解决上述报错,但又有新的报错了
另外,现在这个项目可以用macOS打包吗,打包过程可否指导下,谢谢!
macOSl拉库报错,请帮忙看下是什么原因。
brew install mecab
后解决上述报错,但又有新的报错了
另外,现在这个项目可以用macOS打包吗,打包过程可否指导下,谢谢!
pyqt现在还不支持py3.10及以上
然后你还需要下载data https://drive.google.com/drive/folders/1uElIYRLNakJj-YS0Kd3r3HE-wzeEvrWd?usp=sharing 解压并覆盖BallonsTranslator/ballontranslator下的同名目录
我还没试过macos打包,貌似pytorch支持m1加速?这些我还没条件验证
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [23 lines of output]
Querying qmake about your Qt installation...
Traceback (most recent call last):
File "/Users/chenzhiyu/.pyenv/versions/3.9.13/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 156, in prepare_metadata_for_build_wheel
hook = backend.prepare_metadata_for_build_wheel
AttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/chenzhiyu/.pyenv/versions/3.9.13/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
main()
File "/Users/chenzhiyu/.pyenv/versions/3.9.13/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/Users/chenzhiyu/.pyenv/versions/3.9.13/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 160, in prepare_metadata_for_build_wheel
whl_basename = backend.build_wheel(metadata_directory, config_settings)
File "/private/var/folders/cl/wp12ygrn1cz9gkrlh8n5tls00000gn/T/pip-build-env-4uarrol2/overlay/lib/python3.9/site-packages/sipbuild/api.py", line 46, in build_wheel
project = AbstractProject.bootstrap('wheel',
File "/private/var/folders/cl/wp12ygrn1cz9gkrlh8n5tls00000gn/T/pip-build-env-4uarrol2/overlay/lib/python3.9/site-packages/sipbuild/abstract_project.py", line 87, in bootstrap
project.setup(pyproject, tool, tool_description)
File "/private/var/folders/cl/wp12ygrn1cz9gkrlh8n5tls00000gn/T/pip-build-env-4uarrol2/overlay/lib/python3.9/site-packages/sipbuild/project.py", line 600, in setup
self.update(tool)
File "project.py", line 160, in update
sipbuild.exceptions.UserException
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
装了mecab、pyqt5,但拉库还是报新错,这次实在看不懂是缺了啥,请作者帮忙看看,谢谢!
AttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel'
这还是装pyqt5报的错?
https://stackoverflow.com/questions/65447314/attributeerror-module-sipbuild-api-has-no-attribute-prepare-metadata-for-bui
这里有建议升级pip, 装pyqt5前装pyqt5-sip, 还是不行就试试pyqt6
pyqt5-sip成功,但pyqt5无法安装成功,把requirements.txt里的pyqt5改成pyqt6后,pyqt6安装成功,但拉库报新错
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [6 lines of output]
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/private/var/folders/cl/wp12ygrn1cz9gkrlh8n5tls00000gn/T/pip-install-i9gf2rr9/pkuseg_24ee9a471c02433e9f375ce9c3c36cf8/setup.py", line 5, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
ModuleNotFoundError: No module named 'numpy'
pip install numpy
requirements里的都装上了吗, 按理来说里面有依赖numpy会一起装的所以就没写进去
numpy安装成功,但又跳出来tokenizers无法安装成功
@blacklein 如果不用mangaocr(有其它ocr可选) transformers和tokenizers就不是必装 你可以注释掉这些行再跑源码 https://github.com/dmMaze/BallonsTranslator/blob/430f0321eda0f7b25ce170f5304d2fd57db7bc01/ballontranslator/dl/ocr/init.py#L106-L149
tokenizers安装成功了,多试几次,成功原因不明,但又跳出pkuseg安装失败,醉了
requirements.txt删除pkuseg后拉库成功没有报错,不知道这个pkuseg是否为必要
requirements.txt删除pkuseg后拉库成功没有报错,不知道这个pkuseg是否为必要
试试pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pkuseg-py39
这个主要是给中文分词断句的, 不装的话在设置里关掉自动分行才能用
pip3 install -i pypi.tuna.tsinghua.edu.cn/simple pkuseg-py39
这个安装失败
pip3 install spacy-pkuseg
这个安装成功,可以替代吗?介绍里写着这包是pkuseg的fork,原版是2020年,这个包是2022年的
按照下面修改过的requirements.txt拉包成功(<----表示修改或增加的包)
# To install pytorch cuda (gpu) version, please look https://pytorch.org/
urllib3==1.25.11 # https://github.com/psf/requests/issues/5740
jaconv
Mecab-python3 <----
torch
torchvision
transformers
fugashi
unidic_lite
tqdm
opencv-python==4.5.*
PyQt6 <----
numpy <----
tokenizers <----
shapely
pyclipper
einops
termcolor
bs4
deepl
qtpy
spacy-pkuseg <----
sentencepiece
ctranslate2
data文件夹放入指定文件夹后,运行命令报错
❯ python3 ballontranslator/__main__.py
/Users/chenzhiyu/.pyenv/versions/3.9.12/lib/python3.9/site-packages/qtpy/__init__.py:267: RuntimeWarning: Selected binding "pyqt5" could not be found, using "pyqt6"
warnings.warn('Selected binding "{}" could not be found, '
[INFO ] import_utils:<module>:51 - PyTorch version 1.12.1 available.
[INFO ] import_utils:<module>:51 - PyTorch version 1.12.1 available.
PyTorch version 1.12.1 available.
Traceback (most recent call last):
File "/Users/chenzhiyu/Downloads/BallonsTranslator/ballontranslator/__main__.py", line 44, in <module>
main()
File "/Users/chenzhiyu/Downloads/BallonsTranslator/ballontranslator/__main__.py", line 23, in main
from ui.mainwindow import MainWindow
File "/Users/chenzhiyu/Downloads/BallonsTranslator/ballontranslator/ui/mainwindow.py", line 16, in <module>
from .configpanel import ConfigPanel
File "/Users/chenzhiyu/Downloads/BallonsTranslator/ballontranslator/ui/configpanel.py", line 7, in <module>
from PyQt5 import QtCore
ImportError: cannot import name 'QtCore' from 'PyQt5' (unknown location)
pip3 install -i pypi.tuna.tsinghua.edu.cn/simple pkuseg-py39
这个安装失败
pip3 install spacy-pkuseg
这个安装成功,可以替代吗?介绍里写着这包是pkuseg的fork,原版是2020年,这个包是2022年的 我试了一下,把源码下面这段改成import spacy_pkuseg as pkuseg后似乎没问题(win11) https://github.com/dmMaze/BallonsTranslator/blob/430f0321eda0f7b25ce170f5304d2fd57db7bc01/ballontranslator/utils/text_processing.py#L190 注意第一次分行的时候它会下载自己的模型
按上面修改了,但仍然报错
❯ python3 __main__.py
/Users/chenzhiyu/.pyenv/versions/3.9.12/lib/python3.9/site-packages/qtpy/__init__.py:267: RuntimeWarning: Selected binding "pyqt5" could not be found, using "pyqt6"
warnings.warn('Selected binding "{}" could not be found, '
[INFO ] import_utils:<module>:51 - PyTorch version 1.12.1 available.
[INFO ] import_utils:<module>:51 - PyTorch version 1.12.1 available.
PyTorch version 1.12.1 available.
Traceback (most recent call last):
File "/Users/chenzhiyu/Downloads/BallonsTranslator/ballontranslator/__main__.py", line 44, in <module>
main()
File "/Users/chenzhiyu/Downloads/BallonsTranslator/ballontranslator/__main__.py", line 23, in main
from ui.mainwindow import MainWindow
File "/Users/chenzhiyu/Downloads/BallonsTranslator/ballontranslator/ui/mainwindow.py", line 16, in <module>
from .configpanel import ConfigPanel
File "/Users/chenzhiyu/Downloads/BallonsTranslator/ballontranslator/ui/configpanel.py", line 7, in <module>
from PyQt5 import QtCore
ImportError: cannot import name 'QtCore' from 'PyQt5' (unknown location)
python3 ballontranslator/main.py
python3 ballontranslator/main.py --qt-api pyqt6
好像没用,还是在improt from pyqt5
❯ python3 ballontranslator/__main__.py --qt-api pyqt6
[INFO ] import_utils:<module>:51 - PyTorch version 1.12.1 available.
[INFO ] import_utils:<module>:51 - PyTorch version 1.12.1 available.
PyTorch version 1.12.1 available.
Traceback (most recent call last):
File "/Users/chenzhiyu/Downloads/BallonsTranslator/ballontranslator/__main__.py", line 44, in <module>
main()
File "/Users/chenzhiyu/Downloads/BallonsTranslator/ballontranslator/__main__.py", line 23, in main
from ui.mainwindow import MainWindow
File "/Users/chenzhiyu/Downloads/BallonsTranslator/ballontranslator/ui/mainwindow.py", line 16, in <module>
from .configpanel import ConfigPanel
File "/Users/chenzhiyu/Downloads/BallonsTranslator/ballontranslator/ui/configpanel.py", line 7, in <module>
from PyQt5 import QtCore
ImportError: cannot import name 'QtCore' from 'PyQt5' (unknown location)
pip安装puqt5失败,但brew install pyqt5成功,但似乎没用
File "/Users/chenzhiyu/Downloads/BallonsTranslator/ballontranslator/ui/configpanel.py", line 7, in
from PyQt5 import QtCore
把这行(configpanel.py, line7)改成from qtpy import QtCore

@blacklein qt6可能会有些坑,遇到的话请另外提issue
运行了可以正常工作,但超级吃内存,32G内存吃了20G,运行完内存占用瞬间直接从25G降到5G
后面我打算试试能不能用pyinstaller打包成macOS app,这样用起来方便,但估计应用体积会很大
pyinstaller --clean -F -w __main__.py
打包macOSapp成功,但只有20MB,应该是data和requirements依赖没打包进去
打包参数用的下面,有点挠头了
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(
['__main__.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='__main__',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
app = BUNDLE(
exe,
name='__main__.app',
icon=None,
bundle_identifier=None,
)