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 (aka the CoastSeg folder).
-
⚠️⚠️⚠️Do not run
pip installorconda installinside 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-runpixi shell --lockedto 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 Repository
- 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
1 2
cd CoastSeg # Make sure this folder contains pyproject.toml - Make sure the directory you are at contains the files. You can use the
-
Create + activate the Pixi environment
- This is like
conda install+conda activatein one step, it reads CoastSeg’spixi.lockfile to build the environment and then activates it1pixi shell
- This is like
-
Verify The CoastSeg Environment was Activated
- You should see something like (coastseg) in your terminal prompt.
- You can ignore the
--frozenin the screenshot below - Run the command below to test if CoastSeg is installed in your environment:
1python -c "import coastseg; print('CoastSeg import OK')"
-
Exit the Environment (optional)
- Exit the current Pixi environment:
- Notice how1exit(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 shellif 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/SatelliteShorelines/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 origin -
-
If you get any stange errors about a particular package being incompability try deleting
.pixifolder and try this command again1pixi shell -
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 and specific version of the Transformers library to run our models correctly. Unforuately there are not packages avavilable on conda forge for Windows computers. 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 by following the instructions in How to Install the Zoo workflow.