# Installation

To install the latest version of PythTB simply type in terminal:

    pip install pythtb --upgrade

If you don’t have root access try installing PythTB into your home folder by executing:

    pip install pythtb --upgrade --user

You should now be ready to download and run any of the examples. If you wish, you could also download all example files as a single tar file

> `pythtb-examples.tar.gz`

to untar this file use the following unix command:

    tar -zxf pythtb-examples.tar.gz

If you need more assistance with the installation process, please continue reading.

## More detailed instructions

PythTB is compatible with Python 2.7 and 3.x (Python 2.6 and below are not recommended). To check which version of Python is currently installed on your system, just type:

    python -V

If your Python is not at version 2.7 or 3.x, see Installing or upgrading Python.

These instructions also assume that pip, the standard package manager for Python, is installed on your system. If not, we recommend that you install it. Otherwise, see instructions for Installing without pip.

Once you have python and pip you can install PythTB simply by typing the following into your terminal:

    pip install pythtb --upgrade

Note that pip command should automatically install/upgrade the following python packages if they were not previously installed and upgraded to the latest version:

- numpy

- matplotlib

To bypass the upgrade of these packages:

    pip install --upgrade --upgrade-strategy only-if-needed pythtb

You should now be ready to run any of the examples.

## Older versions of PythTB

If for some reason you wish to install a specific older version of PythTB you can type the following into terminal (replace 1.x.x with version number you wish to install):

    pip install pythtb==1.x.x

To check which version of PythTB you have installed, type:

    pip show pythtb

or print the value of the version number from within a PythTB program:

    print(pythtb.__version__)

## Alternative installation, without ‘pip’

If for any reason you can’t install PythTB using ‘pip’ you can follow these instructions.

PythTB is compatible with Python 2.7 and 3.x (Python 2.6 and below are not recommended). To check which version of Python is currently installed on your system, just type:

    python -V

If your Python is not at version 2.7 or 3.x, see Installing or upgrading Python.

In addition, you will need to have numpy and matplotlib installed. On a Unix/Linux/Mac system, you may be able to install these using your Package Manager. Otherwise, follow the installation instructions at the numpy and matplotlib official websites:

- numpy official website

- matplotlib official website

or install Anaconda version of python.

To install PythTB without ‘pip’ first download either of the following two archived forms

- `pythtb-1.8.0.tar.gz`

- `pythtb-1.8.0.zip`

and unpack it with one of these commands:

    tar -zxf pythtb-1.8.0.tar.gz
    unzip pythtb-1.8.0.zip

Then move into the working directory and install it:

    cd pythtb-1.8.0
    python setup.py install

(You may have to sudo the second command.) To check that the installation was successful, type:

    python

and then execute the following command in python interpreter:

    import pythtb

If you do not see any error message, the installation was successful. Now you can try executing any of the example scripts.

## Installing or upgrading Python

If you do not have Python installed, or it is not at Version 2.7 or higher, follow these instructions.

In Unix/Linux or Mac, use the package manager provided by your system to download and install or upgrade Python and any needed modules. It is recommended to install ‘python2.7’ (or python3.5) and related packages such as ‘python2.7-doc’. If you do not have a package manager, you can try going to the official Python Download Page and follow instructions there to download and install it. Or, try Anaconda, which provides SciPy, NumPy, and Matplotlib already in the distribution.

For Windows, follow the instructions at the official Python site or try Anaconda.

## Additional software

You may wish to try installing ipython; it provides a more user-friendly interactive interface than ‘python’ does.

## Release notes and version list

We recommend you always use latest available version of PythTB. Note that versions up to 1.7.0 are incompatible with Python3. Versions 1.7.1 and above are compatible with both Python 2.7 and 3.x.

However, if you need to look up an old version of the code, you can find it below.

### Version 1.8.0 (current)

20 September 2022: `pythtb-1.8.0.tar.gz`

- Updated class wf_array to make it easier to store states which are not Bloch-like eigenstates.

- Added new functionality to wf_array (solve_on_one_point, choose_states, empty_like)

- Added function change_nonperiodic_vector and changed the way “to_home” parameter works.

- Fixed various small issues.

- Removed some functions that were kept for backwards compatibility (berry_curv, k_path, tbmodel, set_sites, add_hop).

### Version 1.7.2

1 August 2017: `pythtb-1.7.2.tar.gz`

- Added support for deleting orbitals

- Display function now prints hopping distances

### Version 1.7.1

22 December 2016: `pythtb-1.7.1.tar.gz`

- Added support for python 3.x in addition to 2.x

### Version 1.7.0

7 June 2016: `pythtb-1.7.0.tar.gz`

- Added interface with Wannier90 package

- Added support for making bandstructure plots along multi-segment paths in the Brillouin zone

- Added support for hybrid Wannier functions.

- Cleaned up period boundary condition in the wf_array class

- Berry curvature in dimensions higher than 2.

- Fixed bug with reduce_dim. Some hopping terms were not correctly casted as onsite terms.

- Fixed bug in impose_pbc when dim_k is less than dim_r.

### Version 1.6.2

25 February 2013: `pythtb-1.6.2.tar.gz`

- Added support for spinors.

- Added make_supercell method with which one can make arbitrary super-cells of the model and also generate slabs with arbitrary orientation.

### Version 1.6.1

15 November 2012: `pythtb-1.6.1.tar.gz`

- Renamed the code package (previously PyTB) to avoid confusion with other acronyms.

- Built a proper python distribution including documentation and an improved website.

- Streamlined the code to be more consistent in naming conventions.

- Made some improvements and extensions to the calculation of Berry phases and curvatures.

- Added a more powerful method of setting onsite and hopping parameters.

- Removed add_wf function from wf_array object and replaced it with [] operator, and changed the way in which the impose_pbc function is used.

- Added some additional examples.

- For the most part, the code should be backward-compatible with version 1.5. (tb_model, set_onsite, set_hop are named differently but have aliases to names from version 1.5).

### Version 1.5

4 June 2012: `pytb-1.5.tar.gz`