Tableau Desktop snippets

How to setup Python TabPy environment on AWS EC2 (free tier)

Instance setup

Following these steps, you will be able to set up a (free) TabPy cloud server to be used for Tableau Desktop installed on your computer/mac or your on-prem server.

  1. Go to AWS Management Console and log in
TabPy on AWS EC2 demo - step 1

  1. Go to AWS Services => All Services => Compute => EC2
  2. In the Instances (running) you can see if you already have any Instance
  3. To continue press Launch Instances
TabPy on AWS EC2 demo - step 2

  1. Press Launch Instance => Launch Instance (not from template)
  2. Select Ubuntu Server 20.04 LTS (HVM), SSD Volume Type - 64 bit
TabPy on AWS EC2 demo - step 3

  1. Select t2.micro (or select another solution with more power but consider that this may be not included in your free tier)
TabPy on AWS EC2 demo - step 4

  1. Click Configure Instance Detail
TabPy on AWS EC2 demo - step 5

  1. Select Enabled on Auto-assign Public IP

Requests a public IP address from Amazon's public IP address pool, to make your instance reachable from the Internet. In most cases, the public IP address is associated with the instance until it’s stopped or terminated, after which it’s no longer available for you to use. If you require a persistent public IP address that you can associate and disassociate at will, use an Elastic IP address (EIP) instead. You can allocate your own EIP, and associate it to your instance after launch.

  1. Click on Add storage button
  2. Leave default values
TabPy on AWS EC2 demo - step 6

  1. Click Add Tag button
  2. Leave empty the Add tags screen
TabPy on AWS EC2 demo - step 7

  1. Click on Configure Security Group button

Please ask your company security system administrator before selecting the configuration on this screen. Just to make a single basic demo you can choose anywhere from the source IP address but keep in mind that in this way anybody from anywhere could connect to this instance so it is highly recommended that you just use it only for a demo with sample public data.

For this demo, I will go for my IP source.

  1. Fill the custom port for TabPy selecting Custom TCP Rule and the default port value 9004.
TabPy on AWS EC2 demo - step 8

  1. Click on Review and launch button
  2. In the next step, you will review all of your setting, then click on the Launch button.

Key Pair

  1. In the next screen, you have to select a Key Pair if you already have create one or create a new one
  2. I will go fo Create a new key pair and then type the name of it Demo_TabPy
  3. Click Download to download the .pem key file
  4. Then click on Launch Instance button
TabPy on AWS EC2 demo - step 9

    Connect to AWS EC2 instance on Mac

    1. Open Terminal in your Mac
    2. Type cd /Users/myusername/Desktop/Demo_TabPy to move to the folder where you saved the .pem file
    3. Type ls -ltr if you want to list the directory files and check the presence of the Key file
    4. Set the right permission to the key file using the following instruction chmod 400 Demo_TabPy.pem
    5. Go back to your browser and click on the instance name
    TabPy on AWS EC2 demo - step 10

    1. Select your instance and hit the Connect button from the top menu
    2. Go to the SSH client sheet and dopy the connection instruction for terminal (something like ssh -i "Demo_TabPy.pem"
    3. Past it into the terminal and hit enter
    4. You should now be connected to the instance
    TabPy on AWS EC2 demo - step 11

    Check if you have Python installed

    In your terminal screen just type python3 --version to check if Python is installed and which version.

    Download and install PIP

    In your terminal just type curl -O to download PIP, then type to install it.

    TabPy on AWS EC2 demo - step 12

    Install TabPy

    In your terminal screen just type and execute python3 -m pip install tabpy.

    Install other modules

    At this stage you can install other modules that you are going to use later, for example if you want to use geoClassy package just use the following instruction: python3 -m pip install geoClassy.

    Restart your EC2 instance

    To exit the instance you just have to type exit and then you can reconnect with the previous connection instruction ssh -i "Demo_TabPy.pem"

    Launch TabPy

    In your terminal screen just type and execute tabpy.

    TabPy on AWS EC2 demo - step 13

    Configure Tableau Desktop

    Open Tableau desktop and go to Help => Manage analytics and extension connections.

    Go back to your browser and go to the instance summary page: the host name is the value under the Public IPv4 address label while the port is 9004.

    Create a calculated field named Double quantity

    list= []
    for i in _arg1 :
    return list",
    TabPy on AWS EC2 demo - step 14

    Close and terminate your instance

    Please consider closing TabPy and terminate the AWS EC2 instance if you no longer need it after the demo. This will avoid surprise costs and also maintain an open instance and all technical and security issues related.

    To close TabBy just hit CTRL + C from terminal.

    To close the connection to AWS EC2 just type and execute exit from terminal.

    To terminate the AWS EC2 instance you just have to go to the instance summary and hit the Instance state button and then Terminate instance.

    TabPy on AWS EC2 demo - step 15

    You can check if you have running (and maybe costing :-) ) instance from the EC2 home page.

    TabPy on AWS EC2 demo - step 16

Back to Tableau Desktop cookbook page