Skip to content
Harold Solbrig edited this page Feb 23, 2016 · 1 revision

Using python 3

Many of the newer tools will only work with python3. The following instructions should help in getting a python 3 environment established.

Install python 3

To determine whether you already have an image of python 3 installed:

> python 
-bash: python: command not found              --> You need to install python 3 from scratch. 
Python V.M.m (...)  (example: Python 3.5.0)   --> if V is '3' you are already running '3'.  If '2' then:
> python3
Python 3.M.m (...)                            --> you have an image of '3' ready to go.  (If 'M' is less than '5', consider upgrading)
-bash: python3 command not found              --> You need to install an image of python 3

If you need to install python 3, see: https://wiki.python.org/moin/BeginnersGuide/Download

Set up a virtual environment

  1. Install the virtualenv package if necessary
  2. Set up the actual virtual environment
> cd (appropriate directory)
> virtualenv -p python3
virtualenv -p python3 myenv
Running virtualenv with interpreter /Library/Frameworks/Python.framework/Versions/3.5/bin/python3
Using base prefix '/Library/Frameworks/Python.framework/Versions/3.5'
New python executable in (appropriate directory)/myenv/bin/python3
Also creating executable in (appropriate directory)/myenv/bin/python
Installing setuptools, pip, wheel...done.
> . myenv/bin/activate
(myenv) >

You are now using a local python 3 virtual environment. At any point, you can exit the environment by:

(myenv) > deactivate
>
```bash
And re-enter it at a later time by:
> . (appropriate directory/myenv/bin/activate
(myenv) >

Clone this wiki locally