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

.to_preferred() gives "Windows fatal exception: access violation" #2121

Open
YagoMasip opened this issue Jan 12, 2025 · 7 comments
Open

.to_preferred() gives "Windows fatal exception: access violation" #2121

YagoMasip opened this issue Jan 12, 2025 · 7 comments

Comments

@YagoMasip
Copy link

YagoMasip commented Jan 12, 2025

Hello,

When executing this code:

from pint import UnitRegistry

ureg = UnitRegistry(system="SI",
                    autoconvert_offset_to_baseunit=True,
                    auto_reduce_dimensions=True,
                    autoconvert_to_preferred=True)

preferred_units = [ureg.pa, ureg.kelvin]    
ureg.default_preferred_units = preferred_units
print(1*ureg.atm)
print((1*ureg.atm).to_preferred())

I'm getting the following output in the Spyder console:

Windows fatal exception: access violation

Main thread:
Current thread 0x00001ed0 (most recent call first):
Windows fatal exception: access violation

Restarting kernel...

No ouput at all when executed in the Windows terminal.

I'm using:

Python 3.12.3 (tags/v3.12.3:f6650f9, Apr 9 2024, 14:05:25) [MSC v.1938 64 bit (AMD64)]
Pint 0.24.4

Thank you in advance,.

YagoMasip

@andrewgsavage
Copy link
Collaborator

what version of mip do you have installed?

@YagoMasip
Copy link
Author

YagoMasip commented Jan 12, 2025

version 1.14.2,

I have just upgraded to 1.15.0 and the issue persists

@andrewgsavage
Copy link
Collaborator

I think it's related to this:

coin-or/python-mip#385

try using lower versions of mip, if you get it working please post the version

@YagoMasip
Copy link
Author

YagoMasip commented Jan 12, 2025

Checked up to version 1.3.1 the issue with the access violation appears

Previous versions up to 1.3.0 there is no acces violation but other errors are shown, for example this one with version 1.3.0

 File c:\users\yagom\onedrive\documentos\python scripts\01 vle\vle\units.py:23
    print((1*ureg.atm).to_preferred())

  File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\pint\facets\plain\qto.py:190 in to_preferred
    units = _get_preferred(quantity, preferred_units)

  File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\pint\facets\plain\qto.py:336 in _get_preferred
    model = mip_Model()

  File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\mip\model.py:485 in __init__
    from mip import gurobi

  File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\mip\gurobi.py:264
    class SolverGurobi(Solver):

  File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\mip\gurobi.py:267 in SolverGurobi
    ffi.NULL):

NameError: name 'ffi' is not defined

@andrewgsavage
Copy link
Collaborator

coin-or/python-mip#384
it does not work on python 3.12 onwards

@YagoMasip
Copy link
Author

Thank you, I understand the problem is in mip not in pint.

@YagoMasip
Copy link
Author

I have just tried also:

pip install git+https://github.com/coin-or/python-mip.git as sugested in coin-or/python-mip#384 whith also no success.

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

No branches or pull requests

2 participants