Skip to content

Error in pickling and loading mkm setup file in Python 3.10.13 #164

@Shahriar58Hossain

Description

@Shahriar58Hossain

I am trying to follow the 'Refining a Microkinetic Model' tutorial for CatMAP, but am getting the following error when I try to run the model -

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
File ~\anaconda3\envs\CatMap\lib\site-packages\catmap\model.py:447, in ReactionModel.load_data_file(self, overwrite)
    446 try:
--> 447     pickled_data = catmap.pickle.load(open(self.data_file, 'r'))
    448 except:

TypeError: a bytes-like object is required, not 'str'

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
Cell In[7], line 6
      3 from catmap import ReactionModel
      5 mkm_file = 'CO_oxidation.mkm'
----> 6 model = ReactionModel(setup_file=mkm_file)
      7 model.output_variables += ['production_rate']
      8 model.run()

File ~\anaconda3\envs\CatMap\lib\site-packages\catmap\model.py:124, in ReactionModel.__init__(self, **kwargs)
    120 if hasattr(self,'setup_file'): #parse in setup file.
    121     #Note that the syntax is simply python variable definitions.
    122     #This is NOT idiot proof.
    123     self.model_name = self.setup_file.rsplit('.',1)[0]
--> 124     self.load(self.setup_file)

File ~\anaconda3\envs\CatMap\lib\site-packages\catmap\model.py:431, in ReactionModel.load(self, setup_file)
    428             self.parse_headers += ['coverage']
    429         self.parse() #Automatically parse in data.
--> 431 self.load_data_file()
    433 self.set_rxn_options()
    435 self.generate_echem_TS()

File ~\anaconda3\envs\CatMap\lib\site-packages\catmap\model.py:449, in ReactionModel.load_data_file(self, overwrite)
    447     pickled_data = catmap.pickle.load(open(self.data_file, 'r'))
    448 except:
--> 449     pickled_data = catmap.pickle.load(open(self.data_file, 'rb'))
    450 for attr in pickled_data:
    451     if not overwrite:

File ~\anaconda3\envs\CatMap\lib\site-packages\mpmath\ctx_mp_python.py:134, in _mpf.__setstate__(self, val)
--> 134 def __setstate__(self, val): self._mpf_ = from_pickable(val)

File ~\anaconda3\envs\CatMap\lib\site-packages\mpmath\libmp\libmpf.py:41, in from_pickable(x)
     39 def from_pickable(x):
     40     sign, man, exp, bc = x
---> 41     return (sign, MPZ(man, 16), exp, bc)

ValueError: invalid literal for int() with base 16: 'b4dc72365d1651c8f1dfc42e0203944f430bfb4d74ec2f55c2da2a8ba0f8b21b7d0ddbb05405a538c0668d76ccff04b4a8fc13b3L'

I'm also attaching the list of packages in conda environment.

catmap.txt

What is the potential issue here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions