Install CoastSeg with Pixi¶
Pixi warning (please read)
- Keep your local CoastSeg repo up to date, or you will use an outdated CoastSeg.
- This is an editable install: Pixi builds CoastSeg from the code in your local git clone.
- ⚠️⚠️⚠️Do not run pip install or conda install inside a Pixi environment. It can permanently break the environment.⚠️⚠️⚠️
- Usually this is fine but if you start getting import errors use the advice below
- If that happens: delete the .pixi/ folder and re-run pixi shell --locked to reinstall all the dependencies
Table of Contents¶
- Before anything: Install Pixi
- Basic Pixi install (recommended)
- Use Pixi without admin access
- Activate an existing Pixi environment
- Upgrade your Pixi environment
- Pixi Command Reference Table
- FAQs
Before anything: Install Pixi¶
Visit the Pixi installation page and follow instructions to install Pixi in your shell.
Basic Pixi install (recommended)¶
- Clone the CoastSeg repo (shallow clone)
- You only need to do this once
bash git clone --depth 1 https://github.com/SatelliteShorelines/CoastSeg.git
- You only need to do this once
-
Navigate to the CoastSeg Directory
- Make sure the directory you are at contains the files. You can use the
lscommand to list the files.pyproject.tomlpixi.lock
3. Create + activate the Pixi environment - This is like1 2
cd CoastSeg # Make sure this folder contains pyproject.tomlconda install+conda activatein one step, it reads CoastSeg’spixi.lockfile to build the environment and then activates it4. Verify it worked1pixi shell --frozen-
You should see something like (coastseg:all) in your terminal prompt.
-
Test the import:
1python -c "import coastseg; print('CoastSeg import OK')"
- Make sure the directory you are at contains the files. You can use the
-
Exit the Environment (optional)
Exit the current Pixi environment:
1 | |
(coastseg) is no longer in front, this means that we have exited the coastseg environment
Use Pixi without admin access¶
If you cannot install Pixi system-wide, install it into a conda environment:
1 2 3 4 5 | |
Then follow the steps in Basic Pixi install (starting from git clone).
Activate an existing Pixi environment¶
- Activate your pixi environment using the
pixi shellcommand -
Use
pixi shell -e allif you want to use the zoo workflow.1 2
cd <coastseg_location> pixi shell
Upgrade your Pixi environment (get the latest CoastSeg)¶
❗ Reminder (Pixi installed via conda): If you installed Pixi inside > a conda environment (for example coastseg_pixi), activate that conda > environment before running any pixi commands:
1 | |
-
Go to your CoastSeg repo
2. Set the remote connection to CoastSeg on GitHub (if needed)1cd <coastseg_location>-
A
git remoteis a URL pointing to the CoastSeg GitHub repo, used to fetch and pull the latest changes. -
originis just the name of that remote — it could be named anything (like cat).
1git remote add origin https://github.com/Doodleverse/CoastSeg.gitVerify the remote is set up:
You should see something like1git remote -v3. Pull the latest changes1 2
origin https://github.com/SatelliteShorelines/CoastSeg (fetch) origin https://github.com/SatelliteShorelines/CoastSeg (push)If it fails due to local changes:1git pull origin4. Re-create/update the environment from the updated lockfile1 2
git stash git pull origin1pixi shell --frozen -
-
Verify the upgrade
1python -c "import coastseg; print('CoastSeg import OK')"
Pixi Command Reference Table¶
| Command | Description | Conda Equivalent | Documentation |
|---|---|---|---|
pixi shell -e <NAME> |
Activate Pixi environment named <NAME> |
conda activate <NAME> |
Pixi shell docs |
exit |
Exit the current Pixi environment | conda deactivate |
Pixi exit docs |
pixi install |
Install dependencies from pyproject.toml and update pixi.lock |
conda install |
Pixi install docs |
pixi install --frozen |
Install dependencies strictly from pixi.lock without updating it, even if it differs from pyproject.toml |
Install from a conda-lock file | Pixi frozen install docs |
FAQs¶
Why can't I use pip install or conda install inside my pixi environment?¶
Pixi is supposed to managed your dependencies and if you run pip install or conda install those packages get written to a different location on your computer than where your pixi environments get saved. This means when you run pixi shell it won't be able to find any of the dependencies you installed with pip install or conda install.
What is pixi.lock?¶
The pixi.lock file explicitly lists exact versions of Conda and PyPI packages required for each environment defined in pyproject.toml. You can open this file to view detailed package version information and sources (PyPI or Conda Forge).
Wait, what happened to pyproject.toml?¶
The pyproject.toml file remains mostly unchanged, but now includes additional sections to help Pixi configure your Python environments more effectively.
Hold up, what do you mean there are multiple environments?¶
Yeah, that confused me too at first. What's special about pixi is that it can define multiple related environments all within the same file, pyproject.toml.
Why did you separate the environments like this?¶
Great question, I did it because for our zoo workflow we require tensorflow version 2.12 to run our models correctly, which isn't a package avavilable on conda forge for windows machines. Since we want CoastSeg to be available in on conda-forge I opted to make it an optional dependency and a separate environment. But don't worry you can still the third environment called all to be able to use the coastsat and zoo workflows at the same time with the pixi shell -e all command.