Skip to content

Set up Smorphi Blockly for MacOS

Posted on:July 16, 2024 at 04:29 AM

Set up Smorphi Blockly for MacOS

In order to use Smorphi-Blockly on MacOS, you need to install python 3.9 or below. It is recommended to use pyenv as a Python Version Manager on MacOS.

Here’s a step-by-step guide:

Installing pyenv

It is highly recommended to use Homebrew to install software packages.

  1. Install Homebrew (if not already installed): Homebrew is a package manager for macOS that makes it easy to install software packages.

    Follow the instructure here: https://brew.sh/ or execute the command below in your terminal.

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  2. Install pyenv using Homebrew:

    brew install pyenv
  3. Set up pyenv in your shell: First, add the commands to ~/.bashrc by running the following in your terminal:

    echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
    echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
    echo 'eval "$(pyenv init -)"' >> ~/.bashrc

    Then, if you have ~/.profile, ~/.bash_profile or ~/.bash_login, add the commands there as well. If you have none of these, add them to ~/.profile.

    • to add to ~/.profile:

      echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.profile
      echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.profile
      echo 'eval "$(pyenv init -)"' >> ~/.profile
  4. Restart your shell

    for the PATH changes to take effect.

    exec "$SHELL"

Using pyenv to Install and Manage Python Versions

  1. (Optional) List available Python versions: To see which versions of Python are available for installation:

    pyenv install --list
  2. Install a specific Python version: Install a Python version using pyenv:

    pyenv install 3.9.19
  3. Set a global Python version or set a local Python version (per directory):

[Recommended!] Set a specific Python version locally (applies only to the current directory and its subdirectories):

cd ~/Downloads/Smorphi/Smorphi-Blockly-main
pyenv local 3.9.19

Set a specific Python version globally (applies to all shells):

pyenv global 3.9.19
  1. Activate the virtual environment:

    Make sure you’re in the project direcitory:

    cd ~/Downloads/Smorphi/Smorphi-Blockly-main

    then run:

    source myenv/bin/activate

Run the project:

  1. Make sure you’re in the project directory
  2. Run the command:
python start.py

Deactivate the virtual environment:

You can deactivate the virtual environment after work is done.

deactivate