Octez uses Python to build this documentation website (https://tezos.gitlab.io) and for a limited set of utility scripts (although this latter usage of Python is deprecated). This page contains installation instructions for the Python environment.
python 3.10.13. It is recommended to use pyenv to manage the python versions. If you want to use
Follow the installation instructions. In particular, this ensures that
eval "$(pyenv init -)"has been executed first during the shell session, by adding this line to an environment script sourced automatically.
You can use then
pyenv install 3.10.13, followed by:
pyenv local 3.10.13to use
python 3.10.13only in the current directory (and its subdirectories, unless redefined)
pyenv global 3.10.13to set the python version to
pyenv shell 3.10.13to use
python 3.10.13only in the current shell
Before using the python environment for the first time, the dependencies must be installed. To achieve this, run
poetry installin the root of the project.
A typical installation of the above prerequisites (including their own prerequisites) proceeds as follows, see below for full details:
# 1. install pyenv # 2. restart shell, to ensure "pyenv init -" has been evaluated # 3. then install python using pyenv: pyenv install 3.10.13 pyenv global 3.10.13 # 4. install poetry # 5. restart shell, to activate the poetry setup # 6. then install dependencies for Octez using poetry: cd tezos/ poetry install
Installation details for Ubuntu 20.04¶
First, make sure
git are installed, as they are required by the
sudo apt-get install curl git --yes
pyenv to compile Python, you’ll have to install python’s build dependencies:
sudo apt-get install make build-essential libssl-dev zlib1g-dev \ libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \ libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev --yes
pyenv using pyenv-installer:
curl https://pyenv.run | bash
pyenv available in your shell session, add the following
to your shell configuration file,
export PATH="$HOME/.pyenv/bin:$PATH" # add pyenv to path eval "$(pyenv init --path)" # adds pyenv plugins to path eval "$(pyenv init -)" # adds pyenv setup to environment eval "$(pyenv virtualenv-init -)" # adds virtualenv setup to environment
To verify the
pyenv installation, restart your terminal and try
Now we can use
pyenv to install Python 3.10.13 and set it as the
pyenv install 3.10.13 pyenv global 3.10.13
Now verify that the correct version is called when running
python --version # should output 3.10.13
Now, on to installing
poetry. We’ll use poetry’s official installer:
curl -sSL https://install.python-poetry.org -o install-poetry.py python install-poetry.py --version 1.2.2 --yes
pyenv, we need to do some shell setup to put
the shells path. Add the following to your shell configuration file,
Restart the terminal and verify that the correct version is called
poetry --version # should output 1.2.2
Finally, let’s use
poetry to install the python dependencies of
Octez. This command needs to run in the root of the Octez checkout:
cd tezos poetry install
If the installation went well, you should now have the correct version
when executing poetry in the Octez checkout for our main dependency
sphinx-build for documentation):
poetry run sphinx-build --version # should output 4.2.0
Adding new dependencies¶
Dependencies are managed by poetry in the file pyproject.toml.
See the reference for the pyproject.toml files.
The file poetry.lock is generated by running
poetry lock, and must never be changed manually.
poetry.lock and its generator
pyproject.toml must be
copied in this repository.