# <center><i class="fa fa-edit"></i> TensorFlow in Ubuntu </center>
###### tags: `Internship`
:::info
**Goal:**
- [x] Set Up Virtual Environment
- [x] RInstall TensorFlow Pip Package
**Resources:**
[Linuxize Webpage](https://linuxize.com/post/how-to-create-python-virtual-environments-on-ubuntu-18-04/)
[Machine Learning](https://hackmd.io/@Derni/HJQkjlnIP)
:::
### Set Up Virtual Environment
Check python version:
```python3 -V```
Use **venv** module to create virtual environment in Python 3.6 and beyond.
Install python3-venv package that provides venv module:
```sudo apt install python3-venv```
Switch to desired directory to store virtual environments.
Once in directory, run this to create directory called my-project-env containing copies of Python, Pip, and etc.:
```python3 -m venv my-project-env```
Activate virtual environment:
```source my-project-env/bin/activate```
:::success
NOTE: Beginning of '$ PATH' variable in the terminal will now change. Originally, it was just a ```$```, but now it should look like ```(my-project-env) $```.
:::
Now can use pip to install, upgrade, and remove packages.
#### Example: Using Requests Module
Install pip:
```pip install requests```
Verify installation:
```python -c "import requests```
Use httpbin.org for simple HTTP Request and Response service.
Open text editor and create new file called testing.py:
```nano testing.py```
Write following code in file:
```
import requests
r = requests.get('http:httpbin.org/get')
print(r.headers)
```
Close and save file.
Run script:
```python testing.py```
Output should be a dictionary of all header entries:
```{'Connection': 'keep-alive', 'Server': 'gunicorn/19.9.0', 'Date': 'Tue, 18 Sep 2018 16:50:03 GMT', 'Content-Type': 'application/json', 'Content-Length': '266', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Credentials': 'true', 'Via': '1.1 vegur'}```
Deactivate environment:
```deactivate```
### Install TensorFlow Pip Package
Follow steps above to activate virtual environment.
Install:
```pip install --upgrade tensorflow```
Verify:
```python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"```