mondeja / md-ulb-pwrap

Markdown paragraph wrapper using Unicode Line Breaking Algorithm written in Rust with Python bindings.
MIT License
0 stars 0 forks source link

pb after pip install md-ulb-pwrap to use po2md on windows #7

Closed ChristianWia closed 2 weeks ago

ChristianWia commented 1 month ago

Hi. I am fighting since yesterday with the library. The windows installation gives:

C:\Users\Kriss>python -m pip install md-ulb-pwrap
Collecting md-ulb-pwrap
  Using cached md_ulb_pwrap-0.1.1-cp38-none-win_amd64.whl.metadata (1.8 kB)
Using cached md_ulb_pwrap-0.1.1-cp38-none-win_amd64.whl (111 kB)
Installing collected packages: md-ulb-pwrap
Successfully installed md-ulb-pwrap-0.1.1

C:\Users\Kriss>

Folder contents is:

E:\program\Python\Python38\Lib\site-packages\md_ulb_pwrap>dir
 Le volume dans le lecteur E s'appelle Data
 Le numéro de série du volume est 7E40-6036

 Répertoire de E:\program\Python\Python38\Lib\site-packages\md_ulb_pwrap

06/07/2024  11:15    <REP>          .
06/07/2024  11:15    <REP>          ..
06/07/2024  11:15           244 224 md_ulb_pwrap.cp38-win_amd64.pyd
06/07/2024  11:15               131 __init__.py
06/07/2024  11:15    <REP>          __pycache__
               2 fichier(s)          244 355 octets
               3 Rép(s)  310 512 758 784 octets libres

E:\program\Python\Python38\Lib\site-packages\md_ulb_pwrap>

Contents of file ini :

E:\program\Python\Python38\Lib\site-packages\md_ulb_pwrap>type __init__.py
from .md_ulb_pwrap import *

__doc__ = md_ulb_pwrap.__doc__
if hasattr(md_ulb_pwrap, "__all__"):
    __all__ = md_ulb_pwrap.__all__
E:\program\Python\Python38\Lib\site-packages\md_ulb_pwrap>

which make failure when using command: po2md e:/datatable-intro-fr.Rmd --pofiles e:/datatable-intro-fr.po --save e:/datatable-intro-fr2o.md

Traceback (most recent call last):
  File "e:\program\python\python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "e:\program\python\python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "E:\program\Python\Python38\Scripts\po2md.exe\__main__.py", line 4, in <module>
  File "e:\program\python\python38\lib\site-packages\mdpo\po2md\__init__.py", line 6, in <module>
    import md_ulb_pwrap
  File "e:\program\python\python38\lib\site-packages\md_ulb_pwrap\__init__.py", line 1, in <module>
    from .md_ulb_pwrap import *
ImportError: DLL load failed while importing md_ulb_pwrap: La procédure spécifiée est introuvable.

(sklearn-venv) E:\program\Python\Python38\Lib\site-packages\mdpo>

Whats wrong ? Thanks.

ChristianWia commented 1 month ago

When installing version 0.1.0 (i.e. the previous one)

C:\Users\Kriss>python -m pip install md-ulb-pwrap==0.1.0
Collecting md-ulb-pwrap==0.1.0
  Downloading md_ulb_pwrap-0.1.0-cp38-none-win_amd64.whl.metadata (2.0 kB)
Downloading md_ulb_pwrap-0.1.0-cp38-none-win_amd64.whl (113 kB)
   ---------------------------------------- 113.5/113.5 kB 6.5 MB/s eta 0:00:00
Installing collected packages: md-ulb-pwrap
Successfully installed md-ulb-pwrap-0.1.0

C:\Users\Kriss>

the command po2md is now successful po2md e:/datatable-intro-fr.Rmd --pofiles e:/datatable-intro-fr.po --save e:/datatable-intro-fr2o.md

C:\Users\Kriss>dir e:*.md
 Le volume dans le lecteur E s'appelle Data
 Le numéro de série du volume est 7E40-6036
Répertoire de E:\
06/07/2024  21:42            33 040 datatable-intro-fr2o.md
               1 fichier(s)           33 040 octets
               0 Rép(s)  310 513 532 928 octets libres
C:\Users\Kriss>

so there is a problem for Windows with the generated version 0.1.1. Can you have a look ? Thanks.

ChristianWia commented 2 weeks ago

hi, could we expect to have an operational version for Windows ? Thanks.

mondeja commented 2 weeks ago

Sorry for the delay. I think that is fixed by v0.1.2. Could you give a try, please?

ChristianWia commented 2 weeks ago

Hola

Thanks for your reply.

Sorry for the v0.1.2 it is the same behaviour => failure when accessing md_ulb_pwrap Christian.

C:\Users\Kriss>python -m pip uninstall md-ulb-pwrapFound existing installation: md-ulb-pwrap 0.1.0 Uninstalling md-ulb-pwrap-0.1.0:   Would remove:     e:\program\python\python38\lib\site-packages\md_ulb_pwrap-0.1.0.dist-info*     e:\program\python\python38\lib\site-packages\md_ulb_pwrap* Proceed (Y/n)? Y   Successfully uninstalled md-ulb-pwrap-0.1.0

C:\Users\Kriss>python -m pip install md-ulb-pwrap Collecting md-ulb-pwrap   Downloading md_ulb_pwrap-0.1.2-cp38-none-win_amd64.whl.metadata (2.2 kB) Downloading md_ulb_pwrap-0.1.2-cp38-none-win_amd64.whl (111 kB)    ---------------------------------------- 111.7/111.7 kB 3.3 MB/s eta 0:00:00 Installing collected packages: md-ulb-pwrap Successfully installed md-ulb-pwrap-0.1.2

(sklearn-venv) E:\program\Python\Python38\Lib\site-packages\mdpo>po2md e:/datatable-sd-usage.Rmd --wrapwidth 0 --pofiles e:/dat atable-sd-usage-fr.po --save e:/datatable-sd-usage-fr2.Rmd Traceback (most recent call last):   File "e:\program\python\python38\lib\runpy.py", line 194, in _run_module_as_main     return _run_code(code, main_globals, None,   File "e:\program\python\python38\lib\runpy.py", line 87, in _run_code     exec(code, run_globals)   File "E:\program\Python\Python38\Scripts\po2md.exe__main.py", line 4, in   File "e:\program\python\python38\lib\site-packages\mdpo\po2md\init.py", line 6, in     import md_ulb_pwrap   File "e:\program\python\python38\lib\site-packages\md_ulb_pwrap\init__.py", line 1, in     from .md_ulb_pwrap import * ImportError: DLL load failed while importing md_ulb_pwrap: La procédure spécifiée est introuvable.

(sklearn-venv) E:\program\Python\Python38\Lib\site-packages\mdpo>

New directory contents : E:\program\Python\Python38\Lib\site-packages\md_ulb_pwrap>dir Le volume dans le lecteur E s'appelle Data  Le numéro de série du volume est 7E40-6036

 Répertoire de E:\program\Python\Python38\Lib\site-packages\md_ulb_pwrap

01/08/2024  15:12              . 01/08/2024  15:12              .. 01/08/2024  15:12           243 712 md_ulb_pwrap.cp38-win_amd64.pyd 01/08/2024  15:12               131 init.py 01/08/2024  15:12              pycache                2 fichier(s)          243 843 octets                3 Rép(s)  310 334 644 224 octets libres

E:\program\Python\Python38\Lib\site-packages\md_ulb_pwrap>

Le jeudi 1 août 2024 à 14:42:57 UTC+2, Álvaro Mondéjar Rubio ***@***.***> a écrit :  

Sorry for the delay. I think that is fixed by v0.1.2. Could you give a try, please?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

mondeja commented 2 weeks ago

I can not replicate on Python v3.12.4 (6 Jun) on Windows AMD 64 bits. Do you've experienced the same problem with other versions of Python?

Is something probably related with your environment. See https://support.pyxll.com/hc/en-gb/articles/4404027796627--DLL-load-failed-The-specified-procedure-could-not-be-found-when-importing-win32api-or-win32com#:~:text=The%20problem%20occurs%20because%20the,old%20versions%20of%20the%20%22pythoncomXX.

ChristianWia commented 2 weeks ago

Perdona ? I m sorry but I cannot afford myself to regenerate my environement and rebuild all my package dependencies due to existing projects.

Better for you is to investigate what you have changed before delivering the product. To help you I can say that mdpo v2.0.1 works and calls md-ulb-pwrap. When it is not installed, it is not found => obvious

Traceback (most recent call last):   File "E:\program\Python\Python38\lib\runpy.py", line 194, in _run_module_as_main     return _run_code(code, main_globals, None,   File "E:\program\Python\Python38\lib\runpy.py", line 87, in _run_code     exec(code, run_globals)   File "E:\program\Python\Python38\Scripts\po2md.exe__main.py", line 4, in   File "E:\program\Python\Python38\lib\site-packages\mdpo\po2md\init.py", line 6, in     import md_ulb_pwrap ModuleNotFoundError: No module named 'md_ulb_pwrap' When it is installed v0.1.2 or v 0.1.1, the error is what was already signalled:Traceback (most recent call last):   File "E:\program\Python\Python38\lib\runpy.py", line 194, in _run_module_as_main     return _run_code(code, main_globals, None,   File "E:\program\Python\Python38\lib\runpy.py", line 87, in _run_code     exec(code, run_globals)   File "E:\program\Python\Python38\Scripts\po2md.exe\main.py", line 4, in   File "E:\program\Python\Python38\lib\site-packages\mdpo\po2md\init.py", line 6, in     import md_ulb_pwrap   File "E:\program\Python\Python38\lib\site-packages\md_ulb_pwrap\init__.py", line 1, in     from .md_ulb_pwrap import * ImportError: DLL load failed while importing md_ulb_pwrap: La procédure spécifiée est introuvable. That means the entry point is not found in the DLL leading to think the generation has followed a wrong process.

When it is installed with v0.1.0, there is no error:md-ulb-pwrap                        0.1.0 mdpo                                2.0.1 (sklearn-venv) E:\program\Python\Python38\Lib\site-packages>po2md e:/datatable-sd-usage.Rmd --wrapwidth 0 --pofiles e:/datatable-sd-usage-fr.po --save e:/datatable-sd-usage-fr2.Rmd

(sklearn-venv) E:\program\Python\Python38\Lib\site-packages> So, you should be able to explain what makes the difference between the versions 0.1.0 and 2.0.1 of md-ulb-pwrap. Hope this helps you.

Christian. 

Le vendredi 2 août 2024 à 01:21:29 UTC+2, Álvaro Mondéjar Rubio ***@***.***> a écrit :  

I can not replicate on Python v3.12.4 (6 Jun) on Windows AMD 64 bits. Do you've experienced the same problem with other versions of Python? Is something probably related with your environment.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

mondeja commented 2 weeks ago

The unique changes were:

I'm pretty much sure that is related to a misconfiguration of your Python installation. There is a lot of information related to that if you search "DLL The specified procedure could not be found Python" on Google. Please, provide a reproducible example from scratch or at least a reproduction with another Python version rather than 3.8 and we'll be able to fix it.

Closing for now pending further information... Saludos.

ChristianWia commented 2 weeks ago

I am sorry to insist but if I take the last version of md_ulb_pwrap the hasattr(md_ulb_pwrap, "all") is FALSE More of that     print( md_ulb_pwrap.all ) says AttributeError: partially initialized module 'md_ulb_pwrap' has no attribute 'all' (most likely due to a circular import)

No problem, i change from .md_ulb_pwrap import *  into  import md_ulb_pwrap in file init.py then its better for me

Traceback (most recent call last):   File "E:\program\Python\Python38\lib\runpy.py", line 194, in _run_module_as_main     return _run_code(code, main_globals, None,   File "E:\program\Python\Python38\lib\runpy.py", line 87, in _run_code     exec(code, run_globals)   File "E:\program\Python\Python38\Scripts\po2md.exe__main.py", line 7, in   File "E:\program\Python\Python38\lib\site-packages\mdpo\po2md\main.py", line 139, in main     raise SystemExit(run(args=sys.argv[1:])[1])  # pragma: no cover   File "E:\program\Python\Python38\lib\site-packages\mdpo\po2md\main.py", line 122, in run     output = po2md.translate(   File "E:\program\Python\Python38\lib\site-packages\mdpo\po2md\init.py", line 953, in translate     parser.parse(   File "E:\program\Python\Python38\lib\site-packages\mdpo\po2md\init.py", line 622, in leave_block     self._save_current_msgid()   File "E:\program\Python\Python38\lib\site-packages\mdpo\po2md\init__.py", line 429, in _save_current_msgid     translation = md_ulb_pwrap.ulb_wrap_paragraph( AttributeError: module 'md_ulb_pwrap' has no attribute 'ulb_wrap_paragraph'

I reinstall back the old one which works for po2md =>  Successfully installed md-ulb-pwrap-0.1.0

And make the same prints; from .md_ulb_pwrap import *

doc = md_ulb_pwrap.doc print(hasattr(md_ulb_pwrap, "all")) if hasattr(md_ulb_pwrap, "all"):     all = md_ulb_pwrap.all print(all)

bingo ! hasattr(md_ulb_pwrap, "all") is there TRUE and print(all) says ['ulb_wrap_paragraph'] which is the symbol missing in the md-ulb-pwrap-0.1.2 !

So what is the use of 0.1.2 if it exposes nothing ? May be some solution on this side to solve the problem.

Le jeudi 1 août 2024 à 14:42:57 UTC+2, Álvaro Mondéjar Rubio ***@***.***> a écrit :  

Sorry for the delay. I think that is fixed by v0.1.2. Could you give a try, please?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

mondeja commented 2 weeks ago

Probably a change in maturin and/or a change in your environment that has broken the way your machine is currently importing DLLs or how maturin treats them in Windows. Could be an error in maturin, but without further information I don't know.

See the comparison between v0.1.0 and v0.1.1, what are the affected changes? Or see the differences of distributed wheels between v0.1.0 and v0.1.1. I can not do more because don't know how to reproduce the error.