exoplanet-dev / exoplanet

Fast & scalable MCMC for all your exoplanet needs!
https://docs.exoplanet.codes
MIT License
206 stars 52 forks source link

Problems with Installing exoplanet in Window System #144

Open alina-Er opened 3 years ago

alina-Er commented 3 years ago

I followed the instruction in Notes about running on Windows at https://docs.exoplanet.codes/en/stable/user/install/. The first three lines run well, but the last one: python -m pip install -e .[test] produces this on my computer: ERROR: File "setup.py" not found. Directory cannot be installed in editable mode: D:\Python\Jupyter Notebook, and I can't find out what's wrong.

dfm commented 3 years ago

You'll need to run that in the root directory of a checked out version of the the github repo (which it doesn't look like you are). I see that the docs are not very clear about that so I'll try to improve the wording, but also to run the tests, I think you'll need a checked out copy.

alina-Er commented 3 years ago

Thank you very much for your help! I'm pretty new to github so I don't know much about it. I worked with jupyter notebooks and I ran the line in the Anaconda Prompt. The first three lines ran well so I thought it was the right place... Would you like to tell me how to get a checked out version of the repo, and, if I still wish to run the test in the Anaconda Prompt, is there any possible way to make it work?

dfm commented 3 years ago

Ah - I misread your previous comment - sorry! You probably don't actually want to run the tests, you would just like to use exoplanet on Windows right? Try replacing that last line with python -m pip install exoplanet (instead of python -m pip install -e .[test]) and that should do the trick.

alina-Er commented 3 years ago

Sorry for the confusion and thank you for your help! Yes, I just want to use exoplanet on my laptop with Windows system. I wish to use it to analyze TESS data of an exoplanet. After installing exoplanet I noticed there is a note about running on Windows so I also ran those lines. However, the last line didn't go well, as well as the next two lines in the Testing section (all were run in Anaconda Prompt). So I thought the test wasn't passed and I couldn't figure out what was wrong.

To test if everything worked well, I also copied all the codes in Fitting TESS data in the case studies section and pasted them in my jupyter notebook and ran them. But, when it comes to the third cell (titled The transit model in PyMC3):

import exoplanet as xo
import pymc3 as pm
import theano.tensor as tt

import pymc3_ext as pmx
from celerite2.theano import terms, GaussianProcess

def build_model(mask=None, start=None):
    if mask is None:
        mask = np.ones(len(x), dtype=bool)
    with pm.Model() as model:

        # Parameters for the stellar properties
        mean = pm.Normal("mean", mu=0.0, sd=10.0)
        u_star = xo.QuadLimbDark("u_star")

        # Stellar parameters from Huang et al (2018)
        M_star_huang = 1.094, 0.039
        R_star_huang = 1.10, 0.023
        BoundedNormal = pm.Bound(pm.Normal, lower=0, upper=3)
        m_star = BoundedNormal(
            "m_star", mu=M_star_huang[0], sd=M_star_huang[1]
        )
        r_star = BoundedNormal(
            "r_star", mu=R_star_huang[0], sd=R_star_huang[1]
        )

        # Orbital parameters for the planets
        period = pm.Lognormal("period", mu=np.log(bls_period), sd=1)
        t0 = pm.Normal("t0", mu=bls_t0, sd=1)
        r_pl = pm.Lognormal(
            "r_pl",
            sd=1.0,
            mu=0.5 * np.log(1e-3 * np.array(bls_depth))
            + np.log(R_star_huang[0]),
        )
        ror = pm.Deterministic("ror", r_pl / r_star)
        b = xo.distributions.ImpactParameter("b", ror=ror)

        ecs = pmx.UnitDisk("ecs", testval=np.array([0.01, 0.0]))
        ecc = pm.Deterministic("ecc", tt.sum(ecs ** 2))
        omega = pm.Deterministic("omega", tt.arctan2(ecs[1], ecs[0]))
        xo.eccentricity.kipping13("ecc_prior", fixed=True, observed=ecc)

        # Transit jitter & GP parameters
        sigma_lc = pm.Lognormal("sigma_lc", mu=np.log(np.std(y[mask])), sd=10)
        rho_gp = pm.Lognormal("rho_gp", mu=0, sd=10)
        sigma_gp = pm.Lognormal("sigma_gp", mu=np.log(np.std(y[mask])), sd=10)

        # Orbit model
        orbit = xo.orbits.KeplerianOrbit(
            r_star=r_star,
            m_star=m_star,
            period=period,
            t0=t0,
            b=b,
            ecc=ecc,
            omega=omega,
        )

        # Compute the model light curve
        light_curves = pm.Deterministic(
            "light_curves",
            xo.LimbDarkLightCurve(u_star).get_light_curve(
                orbit=orbit, r=r_pl, t=x[mask], texp=texp
            )
            * 1e3,
        )
        light_curve = tt.sum(light_curves, axis=-1) + mean
        resid = y[mask] - light_curve

        # GP model for the light curve
        kernel = terms.SHOTerm(sigma=sigma_gp, rho=rho_gp, Q=1 / np.sqrt(2))
        gp = GaussianProcess(kernel, t=x[mask], yerr=sigma_lc)
        gp.marginal("gp", observed=resid)
        pm.Deterministic("gp_pred", gp.predict(resid))

        # Fit for the maximum a posteriori parameters, I've found that I can get
        # a better solution by trying different combinations of parameters in turn
        if start is None:
            start = model.test_point
        map_soln = pmx.optimize(start=start, vars=[sigma_lc, sigma_gp, rho_gp])
        map_soln = pmx.optimize(start=map_soln, vars=[r_pl])
        map_soln = pmx.optimize(start=map_soln, vars=[b])
        map_soln = pmx.optimize(start=map_soln, vars=[period, t0])
        map_soln = pmx.optimize(start=map_soln, vars=[u_star])
        map_soln = pmx.optimize(start=map_soln, vars=[r_pl])
        map_soln = pmx.optimize(start=map_soln, vars=[b])
        map_soln = pmx.optimize(start=map_soln, vars=[ecs])
        map_soln = pmx.optimize(start=map_soln, vars=[mean])
        map_soln = pmx.optimize(
            start=map_soln, vars=[sigma_lc, sigma_gp, rho_gp]
        )
        map_soln = pmx.optimize(start=map_soln)

    return model, map_soln

model0, map_soln0 = build_model()

there was an Exception occurred:

You can find the C code in this temporary file: C:\Users\alina\AppData\Local\Temp\theano_compilation_error_gmfmvtp8

Exception Traceback (most recent call last)

in 99 100 --> 101 model0, map_soln0 = build_model()
in build_model(mask, start) 64 light_curves = pm.Deterministic( 65 "light_curves", ---> 66 xo.LimbDarkLightCurve(u_star).get_light_curve( 67 orbit=orbit, r=r_pl, t=x[mask], texp=texp 68 ) E:\Apps\Anaconda3\lib\site-packages\exoplanet\light_curves\limb_dark.py in get_light_curve(self, orbit, r, t, texp, oversample, order, use_in_transit, light_delay) 126 tt.zeros_like(r), t.ndim 127 ) + tt.shape_padright(tt.zeros_like(t), r.ndim) --> 128 inds = orbit.in_transit(t, r=r, texp=texp, light_delay=light_delay) 129 t = t[inds] 130 E:\Apps\Anaconda3\lib\site-packages\exoplanet\orbits\keplerian.py in in_transit(self, t, r, texp, light_delay) 773 t_end += 0.5 * texp 774 --> 775 mask = tt.any(tt.and_(dt >= t_start, dt <= t_end), axis=-1) 776 777 result = ifelse( E:\Apps\Anaconda3\lib\site-packages\theano\tensor\var.py in __ge__(self, other) 70 71 def __ge__(self, other): ---> 72 rval = theano.tensor.basic.ge(self, other) 73 rval._is_nonzero = False 74 return rval E:\Apps\Anaconda3\lib\site-packages\theano\gof\op.py in __call__(self, *inputs, **kwargs) 667 668 # compute output value once with test inputs to validate graph --> 669 thunk = node.op.make_thunk(node, storage_map, compute_map, 670 no_recycling=[]) 671 thunk.inputs = [storage_map[v] for v in node.inputs] E:\Apps\Anaconda3\lib\site-packages\theano\gof\op.py in make_thunk(self, node, storage_map, compute_map, no_recycling, impl) 952 compute_map=compute_map, impl='c') 953 try: --> 954 return self.make_c_thunk(node, storage_map, compute_map, 955 no_recycling) 956 except (NotImplementedError, utils.MethodNotDefined): E:\Apps\Anaconda3\lib\site-packages\theano\gof\op.py in make_c_thunk(self, node, storage_map, compute_map, no_recycling) 855 raise NotImplementedError("float16") 856 _logger.debug('Trying CLinker.make_thunk') --> 857 outputs = cl.make_thunk(input_storage=node_input_storage, 858 output_storage=node_output_storage) 859 thunk, node_input_filters, node_output_filters = outputs E:\Apps\Anaconda3\lib\site-packages\theano\gof\cc.py in make_thunk(self, input_storage, output_storage, storage_map, keep_lock) 1213 """ 1214 init_tasks, tasks = self.get_init_tasks() -> 1215 cthunk, module, in_storage, out_storage, error_storage = self.__compile__( 1216 input_storage, output_storage, storage_map, 1217 keep_lock=keep_lock) E:\Apps\Anaconda3\lib\site-packages\theano\gof\cc.py in __compile__(self, input_storage, output_storage, storage_map, keep_lock) 1151 input_storage = tuple(input_storage) 1152 output_storage = tuple(output_storage) -> 1153 thunk, module = self.cthunk_factory(error_storage, 1154 input_storage, 1155 output_storage, E:\Apps\Anaconda3\lib\site-packages\theano\gof\cc.py in cthunk_factory(self, error_storage, in_storage, out_storage, storage_map, keep_lock) 1621 for node in self.node_order: 1622 node.op.prepare_node(node, storage_map, None, 'c') -> 1623 module = get_module_cache().module_from_key( 1624 key=key, lnk=self, keep_lock=keep_lock) 1625 E:\Apps\Anaconda3\lib\site-packages\theano\gof\cmodule.py in module_from_key(self, key, lnk, keep_lock) 1187 try: 1188 location = dlimport_workdir(self.dirname) -> 1189 module = lnk.compile_cmodule(location) 1190 name = module.__file__ 1191 assert name.startswith(location) E:\Apps\Anaconda3\lib\site-packages\theano\gof\cc.py in compile_cmodule(self, location) 1518 try: 1519 _logger.debug("LOCATION %s", str(location)) -> 1520 module = c_compiler.compile_str( 1521 module_name=mod.code_hash, 1522 src_code=src_code, E:\Apps\Anaconda3\lib\site-packages\theano\gof\cmodule.py in compile_str(module_name, src_code, location, include_dirs, lib_dirs, libs, preargs, py_module, hide_symbols) 2408 # prints the exception, having '\n' in the text makes it more 2409 # difficult to read. -> 2410 raise Exception('Compilation failed (return status=%s): %s' % 2411 (status, compile_stderr.replace('\n', '. '))) 2412 elif config.cmodule.compilation_warning and compile_stderr: Exception: ('Compilation failed (return status=1): C:\\Users\\alina\\AppData\\Local\\Temp\\ccDlIzMm.s: Assembler messages:\r. C:\\Users\\alina\\AppData\\Local\\Temp\\ccDlIzMm.s:2304: Error: invalid register for .seh_savexmm\r. ', '[Elemwise{ge,no_inplace}(, )]')

I'm not sure how to deal with it? Does this anything to do with the installation?

P.S., I've checked on my computer and I found exoplanet 0.4.4 has already been installed.

dfm commented 3 years ago

That issue is one that I've hit before (https://github.com/exoplanet-dev/exoplanet/issues/92) but I never found a solution. This is caused by some lower level compiler issue that I've never been able to reproduce and diagnose locally. Can you give me more details about your system setup: e.g. which version of windows, how you installed anaconda, etc. and I'll see what I can do!

alina-Er commented 3 years ago

Of course! I'm using Windows 10 (64-bit), Anaconda3 2020.07. I initially installed Anaconda in E drive (E:), but later I found there was another Anaconda file in my Jupyter Notebook file in D:. I think this may be because I located the base of Jupyter Notebook there?

Please let me know anytime you need more information!

alina-Er commented 3 years ago

By the way, if it is due to the Windows system, will that help if I borrow a Mac with iOS and run the codes?

dfm commented 3 years ago

@Alina6618: This is definitely a Windows-specific issue, but it's one that I'd like to figure out at some point! In the meantime, using a Mac might be easier, but I hope to look into this more soon.

alina-Er commented 3 years ago

Hi, Dan! I appreciate your warm help so much! Thank you for your prompt reply all the time. Looking forward to your new progress!

alex-grajales commented 1 year ago

I am trying to install exoplanet but it tells me in the command prompt that says: ERROR: note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for exoplanet-core Failed to build exoplanet-core ERROR: Could not build wheels for exoplanet-core, which is required to install pyproject.toml-based projects In Spyder says that there is no module called exoplanet