CalebBell / thermo

Thermodynamics and Phase Equilibrium component of Chemical Engineering Design Library (ChEDL)
MIT License
594 stars 114 forks source link

Error on import #37

Closed shimwell closed 4 years ago

shimwell commented 4 years ago

When importing thermo an rnning my program it works fine, however when I use pytest to test some of the functionality of my program it breaks while trying to import thermo.

Does anyone else have this problem

Screenshot from 2020-02-13 18-02-19

CalebBell commented 4 years ago

Hi Jonathan,

I have actually ran into this bug before - I never quite did pin down the exact cause, although it seemed to occur on macs only. When I found it, I changed all open commands to handle everything properly; but this place is new and had not been written at that time, and I neglected to handle this possibility there.

The fix is to edit the identifiers.py file - and add an import at the top of the file, importing the function "open" from the module "io", as follows: "from io import open"

Once that is done, in the "load" function of the "ChemicalMetadataDB" class, the open command needs to take a new keyword argument as well; "f = open(file_name, encoding='utf-8')"

shimwell commented 4 years ago

That sounds straight forward, I can give that a go. I can try a PR once done if that helps.

Just to help anyone else, this error occurred on Ubuntu 18.04 which I guess is closer to Mac than Windows.