Skip to content

Virtual machine and Anaconda installation and configuration


In this part we cover the following topics


Virtual machine installation

This instalation was done on MacBook Air (11-inch, Early 2015), 1,6GHz Intel Core i5, 8GB RAM.


Install Python environment

  • Step 1: install Anaconda
    To install Anaconda you can follow Installing on Linux guide

    Close and open your terminal window for the installation to take effect.


    When we start working with Anaconda, at some point, depending on the sequence of commands we execute, we will see the message similar to the following

    In such a case simply do what is given in this message

    then logout from teminal

    and login back. This should fix the issue.

  • Step 2: working with virtual environment
    • To check virtual environments we have installed

    • To check installed python versions

    • To create new environment

    • To activate/deactivate/delete environment
      In short, we need the following commands

      Bellow is a detiled log

  • Step 3: install Pandas with Anaconda navigator






  • Step 4: write simple Python script to test Pandas
    • Create a ~/Desktop/code/test directory

    • Create data.csv file located in ~/Desktop/code/test directory

      Put the following Python code in it:

    • Create pandas_test.py script file located in ~/Desktop/code/test directory

      Put the following Python code in it
      NOTE: The first line in the following source code points to Python we will use and is system/user dependent - it is highly probable that you should use different path according to your settings!:

    • Test script in terminal

  • Step 5: use Django to have a web interface
    If you need more information about Django, you can start with Writing your first Django app

    • Install Django with command line
    • Create a Django project

      A project directory should laid out like this
    • Run Django developper's server

    • Add Django application to existing Django project
      Open a new terminal tab and type
    • Edit views.py file
      Open the file /home/ubd/Desktop/django/testdjango/testfirst/views.py and put the following Python code in it:
    • Create urls.py file in testfirst application

      In ~/Desktop/django/testdjango/testfirst directory create a file called urls.py

      Put the following Python code in it:
    • Add/edit to project's urls.py file a code
      Add to ~/Desktop/django/testdjango/testdjango/urls.py the following code:
    • Test application
      Go to webbrowser and type http://127.0.0.1:8000/first/ url
    • Add/modify ~/Desktop/django/testdjango/testfirst/urls.py file
    • Create a new view
      Add/edit to ~/Desktop/django/testdjango/testfirst/views.py a new code
    • Test application
      Go to webbrowser and type http://127.0.0.1:8000/first/job url


Summary

At this point we

  • have virtual machine with Xubuntu installed and configured;
  • have Anaconda to manage Python packages installed;
  • know how to activate/deactivate Python virtual environment;
  • know how to write Python scripts and execute them from command line;
  • know how to write Python scripts and execute them from web browser.