Skip to content

Installation for Python3

Yogesh Khatri (@swiftforensics) edited this page Dec 17, 2023 · 14 revisions

Standalone compiled binaries are available for Windows (under Releases), this guide is only for running mac_apt from source code. Please follow the instructions in exact order.

It is recommended to use Python 3.10. Note that 3.11 is currently not supported due to a dependency that does not support it.

Download (or git clone) mac_apt from github, then follow this document to install the dependencies. If you are on macos, there is an installer shell script that does it all automatically.

The recommended method of installation is now via PIP. Run pip with the following command:

pip install -r requirements.txt

Use a version of pip specific to your installation when you have multiple python versions installed. Eg: pip3.10

If you have issues, use these links to jump to specific instructions for your OS:
Windows, Linux & Windows Subsystem for Linux, macOS

Windows

Installing code dependencies:

On windows, pip.exe will be found under your python_install_folder\Scripts\pip.exe
You will need the VC++ compiler to be installed as some dependencies need it. For more information on this, see here.

Errors installing fastchunking (required for pyaff4)

Installation via pip may fail due to a long path issue which can be easily fixed by setting the temporary path environment variable to a folder at the root of the disk.

On the command line redirect the TEMP and TMP folders as follows, then run pip. Just run the following commands to do so:

mkdir C:\temp1
set TEMP=C:\temp1
set TMP=C:\temp1
pip install -r requirements.txt
rmdir /S /Q C:\temp1

Linux and Windows Subsystem for Linux (Bash.exe tested on Ubuntu/Win10)

If you enable Windows Subsystem for Linux and then install Ubuntu from the Microsoft Store, you can use the same steps shown below (which also work on normal Ubuntu Linux). On windows, start by invoking bash.exe. On Linux, start a Terminal window.

sudo apt update
sudo apt install python3.10-pip python3.10-virtualenv python3.10-dev libbz2-dev zlib1g-dev

Setting up a virtual environment

In order to avoid confusion about python libraries, we will lock down our environment using virtualenv. This way any dependencies we install/upgrade/remove will only affect that instance and nothing else. This will avoid hours of frustration later!

sudo pip3.10 install virtualenv
virtualenv env
source env/bin/activate

Download mac_apt

git clone https://github.com/ydkhatri/mac_apt

Installing code dependencies

cd mac_apt
pip3.10 install -r requirements.txt

Thats it! Test this by running

python mac_apt.py -h

You can deactivate the virtualenv when done with a simple deactivate command.

Note: Every time you need to run the script you have to open a terminal, browse to the installation folder and activate the virtualenv with the command
source env/bin/activate


macOS (OSX)

Automated installer

There is an automated install script that will download and install mac_apt and all dependencies. If you wish to use that, download mac_apt_Install_macOS-v24.sh from here, then run the following commands on the Terminal to add execution permission to the file and run it.

chmod u+x mac_apt_Install_macOS-v24.sh
./mac_apt_Install_macOS-v24.sh

Note: Every time you need to run the script you have to open a terminal, browse to the mac_apt folder and activate the virtualenv with the command
source env/bin/activate

Alternatively, if you wish to do install manually, follow the steps below:

Install Homebrew. You will need this to install the other components.

Install python3.10, pip & git

brew install python3.10 git

In order to avoid confusion about python libraries, we will lock down our environment using virtualenv. This way any dependencies we install/upgrade/remove will only affect that instance and nothing else. This will avoid hours of frustration later!

sudo pip3.10 install --upgrade virtualenv

Now go to the extracted mac_apt (source code) folder, from here create the virtual environment, we just call it 'env' here.

cd mac_apt
virtualenv --python python3.10  env

Now activate 'env' with command:

source env/bin/activate

Your environment is setup and ready for use. When you are done with the rest of the installation and need to go back to the regular shell, type deactivate. Run all the commands below in this activated shell only.

Installing code dependencies

cd mac_apt
pip3.10 install -r requirements.txt

You should not need 'sudo' here, as its only writing to our custom environment.

Now that all dependencies are installed, you can run python mac_apt.py -h to run the script (-h shows you available options). You can deactivate the virtualenv when done.

Note: Every time you need to run the script you have to open a terminal, browse to the mac_apt folder and activate the virtualenv with the command
source env/bin/activate


Possible run-time Errors

For run-time problems, see Known-issues-and-Workarounds.