Golang and Python Setup

Golang

sudo apt-get install golang

#Append to the /root/.zshrc and /root/.bashrc files
export PATH=$PATH:/usr/local/go/bin
export PATH=$PATH:$HOME/go/bin/

Python

In 2019 Python 2 support was removed from Kali Linux, but Python2 can still be run by using Pyenv and virtual environments. For more information about virtual environments refer to RealPython's Intro to pyenv and the pyenv Github Page.

Pyenv Setup

#Install dependencies
sudo apt install -y build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python3-openssl git

#Download and run setup script
curl https://pyenv.run | bash

#Update ZSH
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init --path)"\nfi' >> ~/.zshrc

#Execute new shell instance
exec $SHELL

#Install Python2
pyenv install 2.7.18

Pyenv.run Content

##Content of pyenv.run
#!/bin/bash
#
# Usage: curl https://pyenv.run | bash
#
# For more info, visit: https://github.com/pyenv/pyenv-installer
#
index_main() {
    set -e
    curl -s -S -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
}

index_main

##Content of https://.../pyenv/pyenv-installer/master/bin/pyenv-installer
#!/usr/bin/env bash

set -e
[ -n "$PYENV_DEBUG" ] && set -x

if [ -z "$PYENV_ROOT" ]; then
  export PYENV_ROOT="${HOME}/.pyenv"
fi

colorize() {
  if [ -t 1 ]; then printf "\e[%sm%s\e[m" "$1" "$2"
  else echo -n "$2"
  fi
}

# Checks for `.pyenv` file, and suggests to remove it for installing
if [ -d "${PYENV_ROOT}" ]; then
  { echo
    colorize 1 "WARNING"
    echo ": Can not proceed with installation. Kindly remove the '${PYENV_ROOT}' directory first."
    echo
  } >&2
    exit 1
fi

failed_checkout() {
  echo "Failed to git clone $1"
  exit -1
}

checkout() {
  [ -d "$2" ] || git -c advice.detachedHead=0 clone --branch "$3" --depth 1 "$1" "$2" || failed_checkout "$1"
}

if ! command -v git 1>/dev/null 2>&1; then
  echo "pyenv: Git is not installed, can't continue." >&2
  exit 1
fi

if [ -n "${USE_GIT_URI}" ]; then
  GITHUB="git://github.com"
else
  GITHUB="https://github.com"
fi

checkout "${GITHUB}/pyenv/pyenv.git"            "${PYENV_ROOT}"                           "${PYENV_GIT_TAG:-master}"
checkout "${GITHUB}/pyenv/pyenv-doctor.git"     "${PYENV_ROOT}/plugins/pyenv-doctor"      "master"
checkout "${GITHUB}/pyenv/pyenv-installer.git"  "${PYENV_ROOT}/plugins/pyenv-installer"   "master"
checkout "${GITHUB}/pyenv/pyenv-update.git"     "${PYENV_ROOT}/plugins/pyenv-update"      "master"
checkout "${GITHUB}/pyenv/pyenv-virtualenv.git" "${PYENV_ROOT}/plugins/pyenv-virtualenv"  "master"
checkout "${GITHUB}/pyenv/pyenv-which-ext.git"  "${PYENV_ROOT}/plugins/pyenv-which-ext"   "master"

if ! command -v pyenv 1>/dev/null; then
  { echo
    colorize 1 "WARNING"
    echo ": seems you still have not added 'pyenv' to the load path."
    echo
  } >&2

  { # Without args, `init` commands print installation help
    "${PYENV_ROOT}/bin/pyenv" init || true
    "${PYENV_ROOT}/bin/pyenv" virtualenv-init || true
  } >&2
fi

Virtual Environment Setup & Use

#Create a virtual environment (myenv), specifying Python2 in current directory. The system version is used by default
virtualenv myenv --python=python2.7.18

#Use created virtual environment
 . ./myenv/bin/activate
 
#Leave virtual environment
deactivate

#Switch to System
pyenv local system

PyCharm

#Download the latest version from https://www.jetbrains.com/pycharm/download/#section=linux

#Copy to /opt directory
cp -r /home/kali/Downloads/pycharm-community-* /opt

#Extract the .tar.gz file
tar -xf pycharm-community-XXXX.tar.gz

#Create a permanent alias to open on command "pycharm" by adding the following line to ~/.zshrc
alias pycharm='sudo /opt/bin/pycharm_path_to.sh'

Last updated