HARK is an open source project written in Python. It's compatible with both Python 2 and 3, and with the Anaconda distributions of python 2 and 3.
In order to use HARK, you firstly need to download Python and add Python to the PATH. We recommend to install python 3, as eventually support for python 2 will end. If you are not confident about the installation process you can use this step-by-step guide https://realpython.com/installing-python/ .
Next, install text editor for Python. If you do not use Anaconda Python distribution (see below), we recommend Atom. To use Atom for Python, firstly install it (you can use this manual). Next, install the packages for Python, we recommend to install at least autocomplete-python and atom-ide-debugger-python. The last enables debugging the Python scripts, that is to set breakpoints and call variables in certain spot of your code (with increase in your codes' sophistication you will find this tools very helpful in finding bugs).
After installing Python and the text editor, you can install HARK package. The simplest way is to use pip.
To install HARK with pip, at a command line type pip install econ-ark
.
If you prefer to isolate the installation of econ-ark
from the installations of any other python tools and packages, use a virtual environment such as virtualenv.
To install virtualenv
, then to create an environment named econ-ark
, and finally to activate that environment, at a command line type:
cd [directory where you want to store the econ-ark virtual environment]
pip install virtualenv
virtualenv econ-ark
Then for Windows, type:
econ-ark\Scripts\activate.bat
While for Mac or Linux:
source econ-ark/bin/activate
In the both cases, you may see (econ-ark) in your command prompt.
Next, install econ-ark
into your new virtual environment via pip:
pip install econ-ark
!NOTE
If you install econ-ark into the virtual environment, your HARK scripts will not compile unless it is activated.
To do so, type for Windows:
cd [directory where you want to store the econ-ark virtual environment]
econ-ark\Scripts\activate.bat
While for Mac or Linux:
cd [directory where you want to store the econ-ark virtual environment]
source econ-ark/bin/activate
Next, run your script
cd [directory where you located your script]
python YourScript.py
For using the text editor, you also need to configure the environment. If you use Atom, simply type atom
at a command prompt after activating the environment. Atom text editor will open and you will be able to compile your codes which use HARK.
Installing HARK with pip does not give you full access to HARK's many graphical capabilities. One way to access these capabilities is by using Anaconda, which is a distribution of python along with many packages that are frequently used in scientific computing.
- Download Anaconda for your operating system and follow the installation instructions at Anaconda.com.
!NOTE
You can have the default python distribution from python.org and from anaconda, as they do not interfere. However, be careful with setting the PATH. To avoid problems you can eg. set the environment variables path to the default distribution and access anaconda distribution via anaconda prompt.
- Anaconda includes its own virtual environment system called
conda
which stores environments in a preset location (so you don't have to choose). So in order to create and activate an econ-ark virtual environment:
conda create -n econ-ark anaconda
conda activate econ-ark
If you want to install econ-ark
only into this environment, you need to firstly activate the environment and then install econ-ark via pip or conda. In the second case type:
conda install econ-ark::econ-ark
About the differences between conda and pip check https://www.anaconda.com/understanding-conda-and-pip/ .
- Open Spyder, an interactive development environment (IDE) for Python (specifically, iPython). You may be able to do this through Anaconda's graphical interface, or you can do so from the command line/prompt. To do so, simply open a command line/prompt and type
spyder
. Ifecon-ark
is installed into the particular environment, you firstly need activate it and then typespyder
.
spyder
enables debugging the Python scripts, that is to set breakpoints and call variables in certain spot of your code, in order to find bugs (with increase in your codes' sophistication you will find this tools very helpful).
-
To verify that
spyder
has access to HARK try typingpip install econ-ark
into the iPython shell within Spyder. If you have successfully installed HARK as above, you should see a lot of messages saying 'Requirement satisfied'.-
If that doesn't work, you will need to manually add HARK to your Spyder environment. To do this, you'll need to get the code from Github and import it into Spyder. To get the code from Github, you can either clone it or download a zipped file.
-
If you have
git
installed on the command line, typegit clone [email protected]:econ-ark/HARK.git
in your chosen directory (more details here). If you get a permission denied error, you may need to setup SSH for GitHub, or you can clone using HTTPS: 'git clone https://github.com/econ-ark/HARK.git'.- If you do not have
git
available on your computer, you can download the GitHub Desktop app and use it to make a local clone.
- If you do not have
-
If you don't want to clone HARK, but just to download it, go to the HARK repository on GitHub. In the upper righthand corner is a button that says "clone or download". Click the "Download Zip" option and then unzip the contents into your chosen directory.
Once you've got a copy of HARK in a directory, return to Spyder and navigate to that directory where you put HARK. This can be done within Spyder by doing
import os
and then usingos.chdir()
to change directories.chdir
works just like cd at a command prompt on most operating systems, except that it takes a string as input:os.chdir('Music')
moves to the Music subdirectory of the current working directory. Alternatively, you can installecon-ark
from the local repository by navigating to that directory where you put HARK and then typing at the command line:pip install -e .
-
Most of the modules in HARK are just collections of tools. To look at a demonstrations, check repository: * DemARK: Demonstrations of the use of HARK
You will want to obtain your own local copy of these repos using:
git clone https://github.com/econ-ark/DemARK.git
Once you have downloaded them, you will find that the repo contains a notebooks
directory that contains a number of jupyter notebooks. If you have the jupyter notebook tool installed (it is installed as part of Anaconda), you should be able to launch the jupyter notebook app from the command line with the command:
jupyter notebook
If you installed the econ-ark into the particular environment, activate it first and then type jupyter notebook
.
If you want to make changes or contributions (yay!) to HARK, you'll need to have access to the source files. Installing HARK via pip (either at the command line, or inside Spyder) makes it hard to access those files (and it's a bad idea to mess with the original code anyway because you'll likely forget what changes you made). If you are adept at GitHub, you can fork the repo. If you are less experienced, you should download a personal copy of HARK again using git clone
(see part for a new user) or the GitHub Desktop app.
-
Navigate to wherever you want to put the repository and type
git clone [email protected]:econ-ark/HARK.git
(more details here). If you get a permission denied error, you may need to setup SSH for GitHub, or you can clone using HTTPS: 'git clone https://github.com/econ-ark/HARK.git'. -
Then, create and activate a virtual environment.
Install virtualenv if you need to and then type:
virtualenv econ-ark
source econ-ark/bin/activate
For Windows:
virtualenv econ-ark
econ-ark\Scripts\activate.bat
-
Make sure to change to HARK directory, and install HARK's requirements into the virtual environment with
pip install -r requirements.txt
. -
Install locally the econ-ark: navigate to your local repository and then type:
pip install -e .
- To check that everything has been set up correctly, run HARK's tests with
python -m unittest
.
!NOTE
To check the package performance with your local changes, use the same command from the command line (after navigating to your HARK directory):
pip install -e .
If for some reason you want to switch back to the PyPI version:
pip uninstall econ-ark
pip install econ-ark (options)