I have just found libretranslate and tried to install it on a virtual environment on a Tumbleweed and Ubuntu linux pc. Two different ones without success.
I always get the URLError(ConnectionRefusedError(111, 'Connection refused')) when trying to run the already installed server.
That said the installation completes successfully yet running libretranslate I get the error above.
Note as the server comes with several side packages I have not tried to install natively the server on each machine to see if it makes any difference. I used the venv to test it for start.
Please let me know if I have to install it on the machine and not on a venv or something else (like the firewall) is the problem.
Finally I do not know if this is the right Topic to post in. Please transfer this post to whatever topic is relevant.
I have tried to TCP/UDP enable the 5000 port for the server to be free on it but it did not work.
I may have to dig more into it (firewall config) though.
**Edited:
It is not the firewall. I did disable it altogether and I got the same result… posting it:
$ libretranslate --load-only en,el
Updating language models
Found 86 models
Keep 2 models
Downloading English → Greek (1.9) ...
(URLError(ConnectionRefusedError(111, 'Connection refused')),)
(URLError(ConnectionRefusedError(111, 'Connection refused')),)
(URLError(ConnectionRefusedError(111, 'Connection refused')),)
(URLError(ConnectionRefusedError(111, 'Connection refused')),)
Cannot update models (normal if you're offline): Download failed for English → Greek
Traceback (most recent call last):
File "/home/lydia/Documents/ML_SiebelOptimization/.venv/bin/libretranslate", line 8, in <module>
sys.exit(main())
File "/home/lydia/Documents/ML_SiebelOptimization/.venv/lib/python3.10/site-packages/libretranslate/main.py", line 206, in main
app = create_app(args)
File "/home/lydia/Documents/ML_SiebelOptimization/.venv/lib/python3.10/site-packages/libretranslate/app.py", line 186, in create_app
language_target_fallback = languages[1] if len(languages) >= 2 else languages[0]
IndexError: list index out of range
Please note that I installed normally on the system the server, run the libretranslate server (even disabled once more the firewall) and still get the same error. So it is not a specific problem concerning the virtual environment created in python.
$ curl https://pub-dbae765fb25a4114aac1c88b90e94178.r2.dev/v1/translate-en_el-1_9.argosmodel
curl: (7) Failed to connect to pub-dbae765fb25a4114aac1c88b90e94178.r2.dev port 443 after 5 ms: Connection refused
This is a bit of a hack but I currently mirror the argosmodel packages at data.argosopentech.com and you can modify your local package index to point there if Cloudflare is blocking you. I don’t love relying on Cloudflare but Cloudflare is free for us and very fast.
Repoint local index
#!/bin/sh
# Change local package index to data.argosopentech.com
cd ~/.local/cache/argos-translate/
original_string="https://pub-dbae765fb25a4114aac1c88b90e94178.r2.dev/v1/"
replacement_string="https://data.argosopentech.com/argospm/v1/"
# Use sed to replace the string in the file
sed -i "s|$original_string|$replacement_string|g" index.json
Install all packages
Installing with LibreTranslate will flush our locally modified version of the package index so we need to install the packages manually.
#!/bin/env python
import argostranslate
import argostranslate.package
for p in argostranslate.package.get_available_packages():
p.install()
I also wonder if assigning a (sub)domain name to the R2 bucket would alleviate this issue; I know it’s been affecting several people. Public buckets · Cloudflare R2 docs
Argos Translate supports multiple links for packages so I could add a second link pointing to data.argosopentech.com to the package index. Argos Translate currently uses random Round Robin when there are multiple links but I could change that in the code so the second link is just a failover in case Cloudflare fails.
I do not know if the bellow works (your code just added a progress bar) but it would be nice to see some progress while waiting…
#!/env/bin/python
import argostranslate
import argostranslate.package
from tqdm import tqdm
for p in argostranslate.package.get_available_packages():
for i in tqdm(len(argostranslate.package.get_available_packages())):
p.install()