Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Installing flexget in a virtualenv

To avoid clashes with packages installed on your system, FlexGet can be installed in a Python virtualenv. A virtualenv is similar to a chroot, but specific to Python packages. Creating a virtualenv is a simple process. The virtualenv will contain its own Python interpreter and its own versions of downloaded dependencies, separate from the system's packages.

Creating a virtualenv is a standard procedure in a Python web application deployment.

Let's create a folder in which to create the virtualenv:

mkdir ~/virtualenv # or any name you prefer
cd ~/virtualenv

Now, create the virtualenv itself and make it relocatable. For some reason, we have to create a regular virtualenv before making it relocatable:

virtualenv2 flexget 
virtualenv2 flexget --relocatable

Activate the virtualenv. From this point, all commands related to Python will use and affect our virtualenv. The activate script includes commands and aliases that make the shell refer to the interpreter and Python paths inside the virtualenv.

source flexget/bin/activate # activate the virtualenv

Install flexget:

pip install flexget

Drop out of our virtualenv:

deactivate

Start flexget. Running scripts directly from the virtualenv (the bin folder) works because the script's shebang line will refer to the interpreter inside the virtualenv. No need to activate it first:

~/virtualenv/flexget/bin/flexget
# note, the first occurrence of flexget is the name of the virtualenv, 
# while the second is actually the Python flexget script.

Otherwise if you are still inside the virtualenv, you can directly invoke the flexget command:

$ source ~/virtualenv/flexget/bin/activate
$ which flexget
/home/human/virtualenv/flexget/bin/flexget
$ flexget --version
1.2.305
You are on the latest release

Virtualenvs are fully self-contained. Everything you installed above is inside the flexget virtualenv folder; nothing on your system, or even in your home folder has been changed. FlexGet places its configuration file inside ~/.config/flexget, so if you wish to upgrade flexget, you may as well just start from scratch:

rm -r ~/virtualenv/flexget
# goto first step

Otherwise, installing a specific version can be done like this:

pip install flexget==1.2.306
# or
pip install flexget>1.2.305
# this will install the highest version number it can find, if that
# version number is greater than 1.2.305

Or you can also simply update the package:

pip install --upgrade flexget
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment