-
Install Visual Studio Code
-
Create your codespaces and choose VS Code to open your codespaces
- Create a Python virtual environment (Python is already pre-installed) and install required packages
sudo apt-get install python3.8-venv
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
python -m stata_kernel.install
jupyter labextension install jupyterlab-stata-highlight
- Install Stata for Linux. Follow their instruction on your terminal. You need to input serial number, code, and authorization
- In
tar -zxf /home/you/Downloads/Stata15Linux64.tar.gz
part, change/home/you/Downloads/
to your directory - In my case, it's
/workspaces/stata-codespaces/
% sudo -s
cd /tmp/
mkdir statafiles
cd statafiles
tar -zxf /home/you/Downloads/Stata15Linux64.tar.gz
cd /usr/local
mkdir stata15
cd stata15
/tmp/statafiles/install
- After installing Stata, install this Ubuntu package because otherwise it will cause an error when invoking your Stata. Just type yes when you're prompted to
# https://askubuntu.com/questions/895897/error-while-loading-shared-libraries-libpng12-so-0
wget http://archive.ubuntu.com/ubuntu/pool/main/libp/libpng/libpng_1.2.54.orig.tar.xz
tar xvf libpng_1.2.54.orig.tar.xz
cd libpng-1.2.54
./autogen.sh
./configure
make -j8
sudo make install
sudo ldconfig
sudo apt-get install libtool autoconf build-essential pkg-config automake tcsh
- Exit from root by typing
exit
and then you're back to virtual environment
- Add Stata to your $PATH. Note that if you are using Stata MP, for example, then you need to add change
stata15
tostata15-mp
; same thing if you're using Stata SE
- Type
nano ~/.bashrc
on your terminal, it will prompt you to a Nano text editor - Scroll to bottom, and insert the following
# stata path
export PATH="/usr/local/stata15:$PATH"
- Type
source ~/.bashrc
- You will be exited from the virtual environment, but no worries, just type
source .venv/bin/activate
- You should by now be able to invoke Stata by typing
stata
on terminal
- Almost there! You need to change
stata_kernel
configuration a little bit typingnano ~/.stata_kernel.conf
. Refer to this page onGeneral Settings
-stata_path
section
- You're now able to run Stata kernel on Jupyter Notebook using GitHub Codespaces by typing
jupyter notebook
on terminal. Just click open in browser when you're prompted to. Also, you need to input the token. See the censored the part below, that's the token that you're going to use
- Create a new file and choose Stata kernel
- That's it, enjoy!
- Let me know if you have any questions by submitting issues here