rodluger / starry

Tools for mapping stars and planets.
https://starry.readthedocs.io
MIT License
144 stars 33 forks source link

Running starry on WSL #315

Closed RomanAkhmetshyn closed 10 months ago

RomanAkhmetshyn commented 10 months ago

Running Starry on Windows Subsystem for Linux

This is pretty much a tutorial on how to run Starry at its current state if you have Windows, but I will also cover some issues I had during installation. As the name suggests, I could only run Starry on Windows Subsystem for Linux. While trying to run on Windows 11, I have faced the same errors posted in these issues:

https://github.com/rodluger/starry/issues/307#issue-1531465851 https://github.com/rodluger/starry/issues/313#issue-1964461771 https://github.com/rodluger/starry/issues/309#issue-1737001574 https://github.com/rodluger/starry/issues/304#issue-1302380756 https://github.com/rodluger/starry/issues/276#issue-836558054 https://github.com/rodluger/starry/issues/302#issue-1197716784 https://github.com/rodluger/starry/issues/281#issue-866743096 https://github.com/rodluger/starry/issues/261#issue-770493757

Most of them are due to Theano (of course) and, I think, incompatible compiler versions that are installed on Windows. So before you read any further, try to look into the issues above, maybe some may help. I'm very thankful to the people who posted them and the authors who provided valuable solutions. Unfortunately, none worked for me.

Friendly message to the authors: please release the main branch version of Starry. The current version installed by "pip install" does not have changes implemented in this post: https://github.com/rodluger/starry/issues/304#issuecomment-1184569511

So here is how I could make Starry work:

1. Install Windows Subsystem for Linux. It is fairly easy and there are many tutorials on this, so I won't cover it. My WSl version: 2.0.9.0 Ubuntu version (on WSL): 22.04.3 LTS

2. Install Python. I followed this guide here: https://www.scriptinghouse.com/2023/11/install-specific-python-version-on-windows-subsystem-for-linux-wsl.html. I downloaded python 3.9.0 using this command wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tgz. sudo make install may not work at first, so type in the WSl terminal these lines: sudo apt install build-essential sudo apt install libssl-dev libffi-dev libncurses5-dev zlib1g zlib1g-dev libreadline-dev libbz2-dev libsqlite3-dev make gcc Then head back to cd Python-3.9.0/, and ./configure make sudo make install Check if python is installed by typing python3 --version

3 Create Python Virtual Environment on WSL. First of all, Starry requires a specific version of Python (3.9.0, that's why I explicitly installed it just in case, although we can create a virtual environment with any version we like) and specific versions of dependencies.

Friendly message to the authors: Please add all dependencies and their required versions to the new release's requirements. (For example tqdm)

Here is a .yaml file that I used for the creation and package installation for the virtual environment:

name: Starry
channels:
  - conda-forge
  - defaults
dependencies:
  - _libgcc_mutex=0.1=conda_forge
  - _openmp_mutex=4.5=2_kmp_llvm
  - _tflow_select=2.3.0=mkl
  - absl-py=2.1.0=pyhd8ed1ab_0
  - aiohttp=3.9.1=py39hd1e30aa_0
  - aiosignal=1.3.1=pyhd8ed1ab_0
  - alsa-lib=1.2.10=hd590300_0
  - anyio=4.2.0=pyhd8ed1ab_0
  - argon2-cffi=23.1.0=pyhd8ed1ab_0
  - argon2-cffi-bindings=21.2.0=py39hd1e30aa_4
  - arrow=1.3.0=pyhd8ed1ab_0
  - astor=0.8.1=pyh9f0ad1d_0
  - asttokens=2.4.1=pyhd8ed1ab_0
  - astunparse=1.6.3=pyhd8ed1ab_0
  - async-lru=2.0.4=pyhd8ed1ab_0
  - async-timeout=4.0.3=pyhd8ed1ab_0
  - attr=2.5.1=h166bdaf_1
  - attrs=23.2.0=pyh71513ae_0
  - babel=2.14.0=pyhd8ed1ab_0
  - beautifulsoup4=4.12.3=pyha770c72_0
  - bleach=6.1.0=pyhd8ed1ab_0
  - blinker=1.7.0=pyhd8ed1ab_0
  - brotli=1.1.0=hd590300_1
  - brotli-bin=1.1.0=hd590300_1
  - brotli-python=1.1.0=py39h3d6467e_1
  - bzip2=1.0.8=hd590300_5
  - c-ares=1.25.0=hd590300_0
  - ca-certificates=2023.11.17=hbcca054_0
  - cached-property=1.5.2=hd8ed1ab_1
  - cached_property=1.5.2=pyha770c72_1
  - cachetools=5.3.2=pyhd8ed1ab_0
  - cairo=1.18.0=h3faef2a_0
  - certifi=2023.11.17=pyhd8ed1ab_0
  - cffi=1.16.0=py39h7a31438_0
  - charset-normalizer=3.3.2=pyhd8ed1ab_0
  - click=8.1.7=unix_pyh707e725_0
  - colorama=0.4.6=pyhd8ed1ab_0
  - comm=0.2.1=pyhd8ed1ab_0
  - contourpy=1.2.0=py39h7633fee_0
  - cryptography=41.0.7=py39he6105cc_1
  - cycler=0.12.1=pyhd8ed1ab_0
  - dbus=1.13.6=h5008d03_3
  - debugpy=1.8.0=py39h3d6467e_1
  - decorator=5.1.1=pyhd8ed1ab_0
  - defusedxml=0.7.1=pyhd8ed1ab_0
  - entrypoints=0.4=pyhd8ed1ab_0
  - exceptiongroup=1.2.0=pyhd8ed1ab_2
  - executing=2.0.1=pyhd8ed1ab_0
  - expat=2.5.0=hcb278e6_1
  - font-ttf-dejavu-sans-mono=2.37=hab24e00_0
  - font-ttf-inconsolata=3.000=h77eed37_0
  - font-ttf-source-code-pro=2.038=h77eed37_0
  - font-ttf-ubuntu=0.83=h77eed37_1
  - fontconfig=2.14.2=h14ed4e7_0
  - fonts-conda-ecosystem=1=0
  - fonts-conda-forge=1=0
  - fonttools=4.47.2=py39hd1e30aa_0
  - fqdn=1.5.1=pyhd8ed1ab_0
  - freetype=2.12.1=h267a509_2
  - frozenlist=1.4.1=py39hd1e30aa_0
  - gast=0.4.0=pyh9f0ad1d_0
  - gettext=0.21.1=h27087fc_0
  - glib=2.78.3=hfc55251_0
  - glib-tools=2.78.3=hfc55251_0
  - gmp=6.3.0=h59595ed_0
  - google-auth=2.26.2=pyhca7485f_0
  - google-auth-oauthlib=1.2.0=pyhd8ed1ab_0
  - google-pasta=0.2.0=pyh8c360ce_0
  - graphite2=1.3.13=h58526e2_1001
  - grpcio=1.60.0=py39h174d805_0
  - gst-plugins-base=1.22.8=h8e1006c_1
  - gstreamer=1.22.8=h98fc4e7_1
  - h5py=2.10.0=nompi_py39h98ba4bc_106
  - harfbuzz=8.3.0=h3d44ed6_0
  - hdf5=1.10.6=h3ffc7dd_1
  - icu=73.2=h59595ed_0
  - idna=3.6=pyhd8ed1ab_0
  - importlib-metadata=7.0.1=pyha770c72_0
  - importlib_metadata=7.0.1=hd8ed1ab_0
  - importlib_resources=6.1.1=pyhd8ed1ab_0
  - ipykernel=6.29.0=pyhd33586a_0
  - ipython=8.18.1=pyh707e725_3
  - ipywidgets=8.1.1=pyhd8ed1ab_0
  - isoduration=20.11.0=pyhd8ed1ab_0
  - jedi=0.19.1=pyhd8ed1ab_0
  - jinja2=3.1.3=pyhd8ed1ab_0
  - json5=0.9.14=pyhd8ed1ab_0
  - jsonpointer=2.4=py39hf3d152e_3
  - jsonschema=4.21.0=pyhd8ed1ab_0
  - jsonschema-specifications=2023.12.1=pyhd8ed1ab_0
  - jsonschema-with-format-nongpl=4.21.0=pyhd8ed1ab_0
  - jupyter=1.0.0=pyhd8ed1ab_10
  - jupyter-lsp=2.2.2=pyhd8ed1ab_0
  - jupyter_client=8.6.0=pyhd8ed1ab_0
  - jupyter_console=6.6.3=pyhd8ed1ab_0
  - jupyter_core=5.7.1=py39hf3d152e_0
  - jupyter_events=0.9.0=pyhd8ed1ab_0
  - jupyter_server=2.12.5=pyhd8ed1ab_0
  - jupyter_server_terminals=0.5.1=pyhd8ed1ab_0
  - jupyterlab=4.0.10=pyhd8ed1ab_0
  - jupyterlab_pygments=0.3.0=pyhd8ed1ab_0
  - jupyterlab_server=2.25.2=pyhd8ed1ab_0
  - jupyterlab_widgets=3.0.9=pyhd8ed1ab_0
  - keras-preprocessing=1.1.2=pyhd8ed1ab_0
  - keyutils=1.6.1=h166bdaf_0
  - kiwisolver=1.4.5=py39h7633fee_1
  - krb5=1.21.2=h659d440_0
  - lame=3.100=h166bdaf_1003
  - lcms2=2.16=hb7c19ff_0
  - ld_impl_linux-64=2.40=h41732ed_0
  - lerc=4.0.0=h27087fc_0
  - libabseil=20230802.1=cxx17_h59595ed_0
  - libblas=3.9.0=20_linux64_openblas
  - libbrotlicommon=1.1.0=hd590300_1
  - libbrotlidec=1.1.0=hd590300_1
  - libbrotlienc=1.1.0=hd590300_1
  - libcap=2.69=h0f662aa_0
  - libcblas=3.9.0=20_linux64_openblas
  - libclang=15.0.7=default_hb11cfb5_4
  - libclang13=15.0.7=default_ha2b6cf4_4
  - libcups=2.3.3=h4637d8d_4
  - libdeflate=1.19=hd590300_0
  - libedit=3.1.20191231=he28a2e2_2
  - libevent=2.1.12=hf998b51_1
  - libexpat=2.5.0=hcb278e6_1
  - libffi=3.4.2=h7f98852_5
  - libflac=1.4.3=h59595ed_0
  - libgcc-ng=13.2.0=h807b86a_3
  - libgcrypt=1.10.3=hd590300_0
  - libgfortran-ng=13.2.0=h69a702a_3
  - libgfortran5=13.2.0=ha4646dd_3
  - libglib=2.78.3=h783c2da_0
  - libgomp=13.2.0=h807b86a_3
  - libgpg-error=1.47=h71f35ed_0
  - libgrpc=1.60.0=hd6c4280_0
  - libhwloc=2.9.3=default_h554bfaf_1009
  - libiconv=1.17=hd590300_2
  - libjpeg-turbo=3.0.0=hd590300_1
  - liblapack=3.9.0=20_linux64_openblas
  - libllvm15=15.0.7=hb3ce162_4
  - libnsl=2.0.1=hd590300_0
  - libogg=1.3.4=h7f98852_1
  - libopenblas=0.3.25=pthreads_h413a1c8_0
  - libopus=1.3.1=h7f98852_1
  - libpng=1.6.39=h753d276_0
  - libpq=16.1=h33b98f1_7
  - libprotobuf=4.24.4=hf27288f_0
  - libre2-11=2023.06.02=h7a70373_0
  - libsndfile=1.2.2=hc60ed4a_1
  - libsodium=1.0.18=h36c2ea0_1
  - libsqlite=3.44.2=h2797004_0
  - libstdcxx-ng=13.2.0=h7e041cc_3
  - libsystemd0=255=h3516f8a_0
  - libtiff=4.6.0=ha9c0a0a_2
  - libuuid=2.38.1=h0b41bf4_0
  - libvorbis=1.3.7=h9c3ff4c_0
  - libwebp-base=1.3.2=hd590300_0
  - libxcb=1.15=h0b41bf4_0
  - libxcrypt=4.4.36=hd590300_1
  - libxkbcommon=1.6.0=hd429924_1
  - libxml2=2.12.4=h232c23b_1
  - libzlib=1.2.13=hd590300_5
  - llvm-openmp=17.0.6=h4dfa4b3_0
  - lz4-c=1.9.4=hcb278e6_0
  - markdown=3.5.2=pyhd8ed1ab_0
  - markupsafe=2.1.3=py39hd1e30aa_1
  - matplotlib=3.7.1=py39hf3d152e_0
  - matplotlib-base=3.7.1=py39h417a72b_1
  - matplotlib-inline=0.1.6=pyhd8ed1ab_0
  - mistune=3.0.2=pyhd8ed1ab_0
  - mkl=2023.2.0=h84fe81f_50496
  - mkl-service=2.4.0=py39h79394f5_1
  - mpg123=1.32.4=h59595ed_0
  - multidict=6.0.4=py39hd1e30aa_1
  - munkres=1.1.4=pyh9f0ad1d_0
  - mysql-common=8.0.33=hf1915f5_6
  - mysql-libs=8.0.33=hca2cd23_6
  - nbclient=0.8.0=pyhd8ed1ab_0
  - nbconvert=7.14.2=pyhd8ed1ab_0
  - nbconvert-core=7.14.2=pyhd8ed1ab_0
  - nbconvert-pandoc=7.14.2=pyhd8ed1ab_0
  - nbformat=5.9.2=pyhd8ed1ab_0
  - ncurses=6.4=h59595ed_2
  - nest-asyncio=1.5.9=pyhd8ed1ab_0
  - notebook=7.0.6=pyhd8ed1ab_0
  - notebook-shim=0.2.3=pyhd8ed1ab_0
  - nspr=4.35=h27087fc_0
  - nss=3.96=h1d7d5a4_0
  - oauthlib=3.2.2=pyhd8ed1ab_0
  - openjpeg=2.5.0=h488ebb8_3
  - openssl=3.2.0=hd590300_1
  - opt_einsum=3.3.0=pyhc1e730c_2
  - overrides=7.4.0=pyhd8ed1ab_0
  - packaging=23.2=pyhd8ed1ab_0
  - pandoc=3.1.3=h32600fe_0
  - pandocfilters=1.5.0=pyhd8ed1ab_0
  - parso=0.8.3=pyhd8ed1ab_0
  - pcre2=10.42=hcad00b1_0
  - pickleshare=0.7.5=py_1003
  - pillow=10.2.0=py39had0adad_0
  - pip=23.3.2=pyhd8ed1ab_0
  - pixman=0.43.0=h59595ed_0
  - pkgutil-resolve-name=1.3.10=pyhd8ed1ab_1
  - platformdirs=4.1.0=pyhd8ed1ab_0
  - ply=3.11=py_1
  - prometheus_client=0.19.0=pyhd8ed1ab_0
  - prompt_toolkit=3.0.42=hd8ed1ab_0
  - protobuf=4.24.4=py39h60f6b12_0
  - psutil=5.9.7=py39hd1e30aa_0
  - pthread-stubs=0.4=h36c2ea0_1001
  - ptyprocess=0.7.0=pyhd3deb0d_0
  - pulseaudio-client=16.1=hb77b528_5
  - pure_eval=0.2.2=pyhd8ed1ab_0
  - pyasn1=0.5.1=pyhd8ed1ab_0
  - pyasn1-modules=0.3.0=pyhd8ed1ab_0
  - pycparser=2.21=pyhd8ed1ab_0
  - pygments=2.17.2=pyhd8ed1ab_0
  - pyjwt=2.8.0=pyhd8ed1ab_0
  - pyopenssl=23.3.0=pyhd8ed1ab_0
  - pyparsing=3.1.1=pyhd8ed1ab_0
  - pyqt=5.15.9=py39h52134e7_5
  - pyqt5-sip=12.12.2=py39h3d6467e_5
  - pysocks=1.7.1=pyha2e5f31_6
  - python=3.9.18=h0755675_1_cpython
  - python-dateutil=2.8.2=pyhd8ed1ab_0
  - python-fastjsonschema=2.19.1=pyhd8ed1ab_0
  - python-flatbuffers=23.5.26=pyhd8ed1ab_0
  - python-json-logger=2.0.7=pyhd8ed1ab_0
  - python_abi=3.9=4_cp39
  - pytz=2023.3.post1=pyhd8ed1ab_0
  - pyu2f=0.1.5=pyhd8ed1ab_0
  - pyyaml=6.0.1=py39hd1e30aa_1
  - pyzmq=25.1.2=py39h8c080ef_0
  - qt-main=5.15.8=h450f30e_18
  - qtconsole-base=5.5.1=pyha770c72_0
  - qtpy=2.4.1=pyhd8ed1ab_0
  - re2=2023.06.02=h2873b5e_0
  - readline=8.2=h8228510_1
  - referencing=0.32.1=pyhd8ed1ab_0
  - requests=2.31.0=pyhd8ed1ab_0
  - requests-oauthlib=1.3.1=pyhd8ed1ab_0
  - rfc3339-validator=0.1.4=pyhd8ed1ab_0
  - rfc3986-validator=0.1.1=pyh9f0ad1d_0
  - rpds-py=0.17.1=py39h9fdd4d6_0
  - rsa=4.9=pyhd8ed1ab_0
  - send2trash=1.8.2=pyh41d4057_0
  - setuptools=69.0.3=pyhd8ed1ab_0
  - sip=6.7.12=py39h3d6467e_0
  - six=1.16.0=pyh6c4a22f_0
  - sniffio=1.3.0=pyhd8ed1ab_0
  - soupsieve=2.5=pyhd8ed1ab_1
  - sqlite=3.44.2=h2c6b66d_0
  - stack_data=0.6.2=pyhd8ed1ab_0
  - tbb=2021.11.0=h00ab1b0_0
  - tensorboard=2.15.1=pyhd8ed1ab_0
  - tensorboard-data-server=0.7.0=py39hd4f0224_1
  - tensorflow=2.4.1=mkl_py39h4683426_0
  - tensorflow-base=2.4.1=mkl_py39h43e0292_0
  - tensorflow-estimator=2.6.0=py39he80948d_0
  - termcolor=2.4.0=pyhd8ed1ab_0
  - terminado=0.18.0=pyh0d859eb_0
  - tinycss2=1.2.1=pyhd8ed1ab_0
  - tk=8.6.13=noxft_h4845f30_101
  - toml=0.10.2=pyhd8ed1ab_0
  - tomli=2.0.1=pyhd8ed1ab_0
  - tornado=6.3.3=py39hd1e30aa_1
  - tqdm=4.66.1=pyhd8ed1ab_0
  - traitlets=5.14.1=pyhd8ed1ab_0
  - types-python-dateutil=2.8.19.20240106=pyhd8ed1ab_0
  - typing-extensions=4.9.0=hd8ed1ab_0
  - typing_extensions=4.9.0=pyha770c72_0
  - typing_utils=0.1.0=pyhd8ed1ab_0
  - unicodedata2=15.1.0=py39hd1e30aa_0
  - uri-template=1.3.0=pyhd8ed1ab_0
  - urllib3=2.1.0=pyhd8ed1ab_0
  - wcwidth=0.2.13=pyhd8ed1ab_0
  - webcolors=1.13=pyhd8ed1ab_0
  - webencodings=0.5.1=pyhd8ed1ab_2
  - websocket-client=1.7.0=pyhd8ed1ab_0
  - werkzeug=3.0.1=pyhd8ed1ab_0
  - wheel=0.42.0=pyhd8ed1ab_0
  - widgetsnbextension=4.0.9=pyhd8ed1ab_0
  - wrapt=1.16.0=py39hd1e30aa_0
  - xcb-util=0.4.0=hd590300_1
  - xcb-util-image=0.4.0=h8ee46fc_1
  - xcb-util-keysyms=0.4.0=h8ee46fc_1
  - xcb-util-renderutil=0.3.9=hd590300_1
  - xcb-util-wm=0.4.1=h8ee46fc_1
  - xkeyboard-config=2.40=hd590300_0
  - xorg-kbproto=1.0.7=h7f98852_1002
  - xorg-libice=1.1.1=hd590300_0
  - xorg-libsm=1.2.4=h7391055_0
  - xorg-libx11=1.8.7=h8ee46fc_0
  - xorg-libxau=1.0.11=hd590300_0
  - xorg-libxdmcp=1.1.3=h7f98852_0
  - xorg-libxext=1.3.4=h0b41bf4_2
  - xorg-libxrender=0.9.11=hd590300_0
  - xorg-renderproto=0.11.1=h7f98852_1002
  - xorg-xextproto=7.3.0=h0b41bf4_1003
  - xorg-xf86vidmodeproto=2.3.1=h7f98852_1002
  - xorg-xproto=7.0.31=h7f98852_1007
  - xz=5.2.6=h166bdaf_0
  - yaml=0.2.5=h7f98852_2
  - yarl=1.9.4=py39hd1e30aa_0
  - zeromq=4.3.5=h59595ed_0
  - zipp=3.17.0=pyhd8ed1ab_0
  - zlib=1.2.13=hd590300_5
  - zstd=1.5.5=hfc55251_0
  - pip:
      - aesara-theano-fallback==0.1.0
      - arviz==0.12.1
      - astropy==6.0.0
      - astropy-iers-data==0.2024.1.15.0.30.14
      - bokeh==3.3.3
      - cftime==1.6.3
      - deprecat==2.1.1
      - dill==0.3.7
      - exoplanet==0.5.2
      - exoplanet-core==0.2.0
      - fastprogress==1.0.3
      - filelock==3.13.1
      - netcdf4==1.6.5
      - numpy==1.22.1
      - pandas==2.0.3
      - patsy==0.5.6
      - pexpect==4.9.0
      - prompt-toolkit==3.0.43
      - pyerfa==2.0.1.1
      - pymc3==3.11.5
      - pymc3-ext==0.1.1
      - scipy==1.7.3
      - semver==3.0.2
      - setuptools-scm==8.0.4
      - stack-data==0.6.3
      - theano-pymc==1.1.2
      - tzdata==2023.4
      - xarray==2023.12.0
      - xarray-einstats==0.6.0
      - xyzservices==2023.10.1

Note that Starry is not on this list yet We will create an environment using conda. So follow this guide here on how to install miniconda on WSL: https://docs.conda.io/projects/miniconda/en/latest/ Then we will create an environment using conda env create --name Starry -f /mnt/c/users/YourUserName/starry.yaml (I saved my .yaml file in my user directory on Windows). You might want to first navigate to miniconda3 directory.

4 Install Starry. Now activate your environment using conda activate Starry. Run pip install git+https://github.com/rodluger/starry --no-deps (this is the main branch version of Starry that has some fixes).

5 This is not the end though. When you import starry in your python code you will still get errors. They will probably be related to exoplanet-core importing pymc instead of pymc3. So you will have to manually open root\miniconda3\envs\Starry\lib\python3.9\site-packages\exoplanet\orbits\keplarian.py and _root\miniconda3\envs\Starry\lib\python3.9\site-packages\exoplanet\light_curves\limbdark.py and change from exoplanet_core.pymc import ops to from exoplanet_core.pymc3 import ops

This should work and help you to at least get through the basic Starry tutorial. But! When you implement limb darkening and execute plt.plot(time, map.flux(xo=xo, yo=yo, ro=ro, zo=zo)) you will get errors with Tensors having no len() or something. A simple fix that worked for me is to add .eval() every time after map.flux(), like plt.plot(time, map.flux(xo=xo, yo=yo, ro=ro, zo=zo).eval()) You can then install Spyder in WSL's Starry environment to code directly or integrate WSL with VS Code while being on Windows.

Hope that helps.

I may have missed something, so if you get any errors reproducing my steps, feel free to comment. I will try to help, but I'm probably the least skillful person using Starry in terms of coding and working with OSs.

RomanAkhmetshyn commented 10 months ago

Also, I really hope this project will transfer from Theano to Jax

RomanAkhmetshyn commented 10 months ago

you will get errors with Tensors having no len() or something

Is also fixable if you just type starry.config.lazy = False. This is noted in the tutorial so ignore what I said after But!