-
Notifications
You must be signed in to change notification settings - Fork 7
Running code using virtual enviroment
Walter Hugo Lopez Pinaya edited this page Dec 31, 2019
·
2 revisions
System requirements
- pip 19.0 or later
- Ubuntu 16.04 or later (64-bit)
Check if your Python environment is already configured:
$ python3 --version
$ pip3 --version
$ virtualenv --version
If these packages are already installed, skip to the next step. Otherwise, install Python, the pip package manager, and Virtualenv:
$ sudo apt update
$ sudo apt install python3-dev python3-pip
$ sudo pip3 install -U virtualenv # system-wide install
Python virtual environments are used to isolate package installation from the system.
Create a new virtual environment by choosing a Python interpreter and making a ./venv directory to hold it:
$ virtualenv --system-site-packages -p python3 ./venv
Activate the virtual environment using a shell-specific command:
$ source ./venv/bin/activate # sh, bash, ksh, or zsh
When virtualenv is active, your shell prompt is prefixed with (venv).
Install packages within a virtual environment without affecting the host system setup. Start by upgrading pip:
(venv) $ pip install --upgrade pip
(venv) $ pip list # show packages installed within the virtual environment
And to exit virtualenv later:
(venv) $ deactivate
Note: Step-by-step based on https://www.tensorflow.org/install/pip?lang=python3