Project

General

Profile

Actions

HowTo create an Ubuntu Environment and make it run with python

STEP 1:
- Get the latest version of Ubuntu here: https://www.ubuntu.com/download/desktop
- Download the latest version of Virtual Box here: https://www.virtualbox.org/wiki/Downloads

STEP 2:
- Create a virtual machine in VB and install the ubuntu you just downloaded by following the directions of VB.

STEP 3:
- Install guest additions following the steps bellow:

1. First start by updating your Ubuntu guest operating system software packages using following command.
$ sudo apt update
$ sudo apt upgrade
2. Once upgrade completes, reboot your Ubuntu guest operating system to effect the recent upgrades and install required packages as follows.
$ sudo apt install build-essential dkms linux-headers-$(uname -r)
3. Next, from the Virtual Machine menu bar, go to Devices => click on Insert Guest Additions CD image as shown in the screenshot. 
This helps to mount the Guest Additions ISO file inside your virtual machine.
4. Next, you will get a dialog window, prompting you to Run the installer to launch it. If not then just double click on the CD image 
located on the desktop and at the dialog window that opens pres Run Software at the top right corner.
5. A terminal window will be opened from which the actual installation of VirtualBox Guest Additions will be performed. 
Once the installation is complete, press [Enter] to close the installer terminal window. Then power off your Ubuntu guest OS
to change some settings from VirtualBox manager as explained in the next step.
6. Now to enable Shared Clipboard and Drag’n’Drop functionality between Guest and Host Machine. Go to General => Advanced and enable the two options
(Shared Clipboard and Drag’n’Drop) as you wish, from the drop down options. Then click OK to save the settings and boot your system,
login and test if everything is working fine.
DONE with guest additions!

STEP 4:
- To fix the network and change it to Bridge Adapter you do the following:

1. At the VB center go to Settings -> Network
2. Change Attached to: Bridged Adapter ( note the Name should change automatically but if not just select the wireless name 
(You can check the name on your pc's network settings)
3. Click Advanced and change Promiscuous Mode: Allow VMs
4. Click OK and start the VM to verify that you have internet access.
NOTE: If you are working on a network like UOW, chances are you won't have internet access. In order to access it while working 
under UOW's network enable Adapter to (Settings -> Network) and set it to NAT.

STEP 5:
- To install python 3 on your machine:

1. First update and upgrade your system to ensure that your shipped version of Python 3 is up-to-date.
$ sudo apt update
$ sudo apt -y upgrade
2. Check which version of Python 3 is installed by typing:
$ python3 -V
It should be something similar to: Python 3.6.5
3. To manage software packages for Python, install pip, a tool that will install and manage libraries or modules to use in your projects.
$ sudo apt install -y python3-pip
4. Python packages can be installed by typing:
$ pip3 install package_name
Here, package_name can refer to any Python package or library, such as Django for web development or NumPy for scientific computing. 
So if you would like to install NumPy, you can do so with the command:
$ pip3 install numpy.
5. There are a few more packages and development tools to install to ensure that we have a robust set-up for our programming environment:
$ sudo apt install build-essential libssl-dev libffi-dev python3-dev
6. Virtual environments enable you to have an isolated space on your machine for Python projects. We’ll use venv, part of the standard Python 3 library, 
which we can install by typing:
$ sudo apt install python3-venv
7. You can create a new environment with the pyvenv command. Here, we’ll call our new environment my_env, but you can call yours whatever you want.
$ python3.6 -m venv my_env
8. Activate the environment using the command below, where my_env is the name of your programming environment.
$ source my_env/bin/activate
Your command prompt will now be prefixed with the name of your environment.
9. Open the Python interpreter:
$ python
NOTE: within the Python 3 virtual environment, you can use the command python instead of python3, and pip instead of pip3.
You’ll know you’re in the interpreter when you receive the following output:
Python 3.6.5 (default, Apr  1 2018, 05:46:30) 
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
Now, use the print() function to create the traditional Hello, World program:
print("Hello, World!")
Output:
Hello, World!
10. Deactivate Virtual Environment
Quit the Python interpreter:
quit()
Then exit the virtual environment:
$ deactivate

DONE!

Updated by Peter Qian about 4 years ago · 1 revisions