Python Environment Guest Ubuntu VM setup - kcbear/ai-essential GitHub Wiki

https://blogs.vmware.com/teamfusion/2024/05/fusion-pro-now-available-free-for-personal-use.html

VMware Fusion Pro Download

  • Be mindful about initial disk space allocation in VMware as you cannot reduce it afterwards(only increase)

https://partnerweb.vmware.com/GOSIG/home.html

https://ubuntu.com/download/server/arm

  • OS username: kcbear

keyless login

  • Going forward using ssh into the VM with NAT configuration

https://www.strongdm.com/blog/ssh-passwordless-login

GUI X forwarding over ssh

  • sudo apt install xauth x11-apps
  • sudo systemctl restart ssh

You’ll need an X11 server running on your macOS host to display the graphical applications. The most popular one is XQuartz.

Install XQuartz on macOS:

Download the latest version of XQuartz from here. Install the package and restart your macOS machine if required. Launch XQuartz:

Open XQuartz from the Applications folder after installation. It should now be running in the background.

Activate the Virtual Environment (if it’s not already activated):

Install Tkinter in the Virtual Environment: Use the system package manager apt to install tkinter, as it’s not part of the Python package index (pip):

  • sudo apt install python3-tk


No VM guests are running outdated hypervisor (qemu) binaries on this host.
(ml) kcbear@ubuntu64:~$ python3
Python 3.12.3 (main, Jan 17 2025, 18:03:48) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
>>> import matplotlib
>>> matplotlib.use('TkAgg')  # Use TkAgg backend
>>> import matplotlib.pyplot as plt
>>> plt.plot([0, 1, 2], [0, 1, 4])

[<matplotlib.lines.Line2D object at 0xffcd46d25100>]
>>> plt.show()

image

To avoid stating plt explicitly everytime

import matplotlib
matplotlib.use('TkAgg')  # Use TkAgg backend
import matplotlib.pyplot as plt

On Linux or macOS: ~/.config/matplotlib/matplotlibrc, create or modify such file:

backend: TkAgg

SETUP PYTHON

sudo apt install python3-pip

sudo apt install python3-venv

python3 -m venv ml

Activate the virtual environment:

- source ml/bin/activate


After activating the environment, your prompt will change to indicate you're working within the virtual environment.

Install the required packages: Now you can install the packages within the virtual environment:

- pip install numpy scipy scikit-learn pandas matplotlib statsmodels

Deactivate the virtual environment when you're done:

- deactivate

ML step by step

https://machinelearningmastery.com/machine-learning-in-python-step-by-step/