It doesn't take much to get
stata_kernel up and running. Here's how:
- Stata. A currently-licensed version of Stata must already be installed.
stata_kernelhas been reported to work with at least Stata 13+, and may work with Stata 12.
Python. In order to install the kernel, Python 3.5, 3.6, or 3.7 needs to be installed on the computer on which Stata is running.
I suggest installing the Anaconda distribution. This doesn't require administrator privileges, and is the simplest way to install Python and many of the most popular scientific packages.
The full Anaconda installation is quite large, and includes many libraries for Python that
stata_kerneldoesn't use. If you don't plan to use Python and want to use less disk space, install Miniconda, a bare-bones version of Anaconda. Then when installing the package any other necessary dependencies will be downloaded automatically.
In order to let
stata_kernel talk to Stata, you need to link the Stata Automation library:
- In the installation directory (most likely
C:\Program Files (x86)\Stata15or similar), right-click on the Stata executable, for example,
Create Shortcut. Placing it on the Desktop is fine.
- Right-click on the newly created
Shortcut to StataSE.exe, choose
Property, and append
/Registerto the end of the Target field. So if the target is currently
"C:\Program Files\Stata15\StataSE.exe", change it to
"C:\Program Files\Stata15\StataSE.exe" /Register. Click
- Right-click on the updated
Shortcut to StataSE.exe; choose
Run as administrator.
To install the kernel, from a terminal or command prompt run:
pip install stata_kernel python -m stata_kernel.install
If Python 2 is the default version of Python on your system, you may need to use
pip3 install stata_kernel python3 -m stata_kernel.install
In order to get syntax highlighting in Jupyter Lab, run:
conda install -c conda-forge nodejs -y jupyter labextension install jupyterlab-stata-highlight
If you didn't install Python from Anaconda, the
conda command won't work and you'll need to install Node.js directly before running
jupyter labextension install.
To upgrade from a previous version of
stata_kernel, from a terminal or command prompt run
pip install stata_kernel --upgrade
When upgrading, you don't have to run
python -m stata_kernel.install again.