Run python virtualenv with ubuntu

By default, my ubuntu runs python2.7 (i.e. simply run python –version).

This comes from /usr/bin/python –> /usr/bin/python2.7

I changed the link to point to python3 instead.

BIG MISTAKE

Python is used all over the place by the system => apt-get update kept failing so I had to revert back to python2.7 link

To use virtualenv with python3, things are pretty easy, you simply need to prefix your commands:

sudo apt-get install python3-pip
sudo pip3 install virtualenv

To create a virtualenv:

  1. Go to folder where you want to create the virtual env:
    cd /path/to/my/project
  2. To create virtual env, run:
    virtualenv-3-4 myvirtualenv
  3. To activate virtual env, run:
    source bin/myvirtualenv/bin/activate

    your shell should be prefixed with (myvirtualenv)
    run:

    pip3 list

    you should only see a few minimal modules installed, different from your system-wide python3 installation

  4. To exit virtual env, run:
    deactivate

 

Post a Comment

Your email is never published nor shared. You're allow to say what you want...