jpn-- / larch

Larch: a Python tool for choice modeling
http://larch.newman.me
GNU General Public License v3.0
41 stars 14 forks source link

No module named 'larch.model.controller' #13

Closed jinsanity07git closed 2 years ago

jinsanity07git commented 3 years ago

Hi Jeff,

I run the jupyter notebook which requres to import larch in my personal python environment. The version I download is version = '5.5.2' However I got the error shows as below:

----> 5 from .controller import Model5c as _Model5c 6 from ..dataframes import DataFrames, get_dataframe_format 7 from .linear import LinearFunction_C, DictOfLinearFunction_C

ModuleNotFoundError: No module named 'larch.model.controller'

I am wondering if the controller.py missing in the model directory.

jinsanity07git commented 3 years ago

solve it by adding a new package on the header to help the pyx file be compiled into a Cython file

import pyximport
pyximport.install()

However, another error pops up.


Error compiling Cython file:
------------------------------------------------------------
...

use_tooltips = False

cdef class LinearComponent_C:

    def __init__(self, unicode param, unicode data='1', l4_float_t scale=1):
                                                    ^
------------------------------------------------------------

larch/model/linear.pyx:418:53: 'l4_float_t' is not a type identifier

Is there a way to fix it?

jpn-- commented 3 years ago

Sorry for the long delay in replying to this thread, I didn't see it originally.

It seems you're having trouble when using larch compiled from source. While this should in theory work, it's tricky sometimes getting the compiler to run and link everything correctly. It's way easier to use the pre-compiled binaries from conda-forge, unless there's some reason you can't?