Environment pip version: 20.0 Python version: 3.6.8 OS: Ubuntu 14.04.6 (Don't judge) Description During our build process, we automatically upgrade to the newest version on pip. After upgrading. Doing it Right¶. Let’s install a real version of Python. Before installing Python, you’ll need to install GCC. GCC can be obtained by downloading Xcode, the smaller Command Line Tools (must have an Apple account) or the even smaller OSX-GCC-Installer package.

Mac OS X comes with Python 2.7 out of the box.

You do not need to install or configure anything else to use Python 2. Theseinstructions document the installation of Python 3.

The version of Python that ships with OS X is great for learning, but it’s notgood for development. The version shipped with OS X may be out of date from theofficial current Python release,which is considered the stable production version.

Doing it Right¶

Let’s install a real version of Python.

Before installing Python, you’ll need to install GCC. GCC can be obtainedby downloading Xcode, the smallerCommand Line Tools (must have anApple account) or the even smaller OSX-GCC-Installerpackage.

Note

Mac install python3 pip

If you already have Xcode installed, do not install OSX-GCC-Installer.In combination, the software can cause issues that are difficult todiagnose.

Note

If you perform a fresh install of Xcode, you will also need to add thecommandline tools by running xcode-select--install on the terminal.

While OS X comes with a large number of Unix utilities, those familiar withLinux systems will notice one key component missing: a package manager.Homebrew fills this void.

To install Homebrew, open Terminal oryour favorite OS X terminal emulator and run

The script will explain what changes it will make and prompt you before theinstallation begins.Once you’ve installed Homebrew, insert the Homebrew directory at the topof your PATH environment variable. You can do this by adding the followingline at the bottom of your ~/.profile file

If you have OS X 10.12 (Sierra) or older use this line instead

Now, we can install Python 3:

This will take a minute or two.

Pip¶

Homebrew installs pip pointing to the Homebrew’d Python 3 for you.

Working with Python 3¶

At this point, you have the system Python 2.7 available, potentially theHomebrew version of Python 2 installed, and the Homebrewversion of Python 3 as well.

will launch the Homebrew-installed Python 3 interpreter.

will launch the Homebrew-installed Python 2 interpreter (if any).

will launch the Homebrew-installed Python 3 interpreter.

If the Homebrew version of Python 2 is installed then pip2 will point to Python 2.If the Homebrew version of Python 3 is installed then pip will point to Python 3.

The rest of the guide will assume that python references Python 3.

Pipenv & Virtual Environments¶

The next step is to install Pipenv, so you can install dependencies and manage virtual environments.

A Virtual Environment is a tool to keep the dependencies required by different projectsin separate places, by creating virtual Python environments for them. It solves the“Project X depends on version 1.x but, Project Y needs 4.x” dilemma, and keepsyour global site-packages directory clean and manageable.

For example, you can work on a project which requires Django 1.10 while alsomaintaining a project which requires Django 1.8.

So, onward! To the Pipenv & Virtual Environments docs!

This page is a remixed version of another guide,which is available under the same license.

Warning

For safety reasons, DO NOT install Red with a root user. If you are unsure how to createa new user on Linux, see this guide by DigitalOcean.

Installing the pre-requirements¶

Mac install python 3 pipes

Please install the pre-requirements using the commands listed for your operating system.

The pre-requirements are:
Mac Install Python3 Pip
  • Python 3.8.1 or greater; Python 3.9 is currently not supported!

  • Pip 18.1 or greater

  • Git 2.11+

  • Java Runtime Environment 11 (for audio support)

We also recommend installing some basic compiler tools, in case our dependencies don’t providepre-built “wheels” for your architecture.

Operating systems¶

Continue by Creating a Virtual Environment.

In order to install Git 2.11 or greater, we recommend adding the IUS repository:

Complete the rest of the installation by installing Python 3.8 with pyenv.

Complete the rest of the installation by installing Python 3.8 with pyenv.

We recommend installing pyenv as a method of installing non-native versions of python onDebian/Raspbian Buster. This guide will tell you how. First, run the following commands:

Complete the rest of the installation by installing Python 3.8 with pyenv.

Fedora Linux 31 and above has all required packages available in official repositories. Installthem with dnf:

Continue by Creating a Virtual Environment.

Install Brew: in Finder or Spotlight, search for and open Terminal. In the terminal, paste thefollowing, then press Enter:

After the installation, install the required packages by pasting the commands and pressing enter,one-by-one:

Mac Install Python 3 Pipes

Continue by Creating a Virtual Environment.

We recommend installing a community package to get Python 3.8 on openSUSE Leap 15.1+. This package willbe installed to the /opt directory.

First, add the Opt-Python community repository:

Now install the pre-requirements with zypper:

Since Python is now installed to /opt/python, we should add it to PATH. You can add a file in/etc/profile.d/ to do this:

Now, install pip with easy_install:

Continue by Creating a Virtual Environment.

openSUSE Tumbleweed has all required dependencies available in official repositories. Install themwith zypper:

Continue by Creating a Virtual Environment.

We recommend adding the git-core ppa to install Git 2.11 or greater:

We recommend adding the deadsnakes ppa to install Python 3.8.1 or greater:

Now install the pre-requirements with apt:

Continue by Creating a Virtual Environment.

We recommend adding the git-core ppa to install Git 2.11 or greater:

Now install the pre-requirements with apt:

Continue by Creating a Virtual Environment.

We recommend adding the git-core ppa to install Git 2.11 or greater:

Now, to install non-native version of python on non-LTS versions of Ubuntu, we recommendinstalling pyenv. To do this, first run the following commands:

And then complete the rest of the installation by installing Python 3.8 with pyenv.

Installing Python with pyenv¶

Note

If you followed one of the sections above, and weren’t linked here afterwards, you should skipthis section.

On distributions where Python 3.8 needs to be compiled from source, we recommend the use of pyenv.This simplifies the compilation process and has the added bonus of simplifying setting up Red in avirtual environment.

After this command, you may see a warning about ‘pyenv’ not being in the load path. Follow theinstructions given to fix that, then close and reopen your shell.

Then run the following command:

This may take a long time to complete, depending on your hardware. For some machines (such asRaspberry Pis and micro-tier VPSes), it may take over an hour; in this case, you may wish to removethe CONFIGURE_OPTS=--enable-optimizations part from the front of the command, which willdrastically reduce the install time. However, be aware that this will make Python run about 10%slower.

After that is finished, run:

Pyenv is now installed and your system should be configured to run Python 3.8.

Continue by Creating a Virtual Environment.

Creating a Virtual Environment¶

Tip

If you want to learn more about virtual environments, see page: About Virtual Environments

We require installing Red into a virtual environment. Don’t be scared, it’s verystraightforward.

You have 2 options:

  • Using venv (quick and easy, involves just two commands)

  • Using pyenv virtualenv (only available and recommended when you installed Python with pyenv)

Using venv

This is the quickest way to get your virtual environment up and running, as venv is shipped withpython.

First, choose a directory where you would like to create your virtual environment. It’s a good ideato keep it in a location which is easy to type out the path to. From now, we’ll call itredenv and it will be located in your home directory.

Create your virtual environment with the following command:

And activate it with the following command:

Important

Mac Install Python3 Pip

You must activate the virtual environment with the above command every time you open a newshell to run, install or update Red.

Continue by Installing Red.

Using pyenvvirtualenv

Mac

Using pyenvvirtualenv saves you the headache of remembering where you installed your virtualenvironments. This option is only available if you installed Python with pyenv.

First, ensure your pyenv interpreter is set to python 3.8.1 or greater with the following command:

Now, create a virtual environment with the following command:

Replace <name> with whatever you like. If you ever forget what you named it,you can always use the command pyenvversions to list all virtual environments.

Now activate your virtualenv with the following command:

Important

You must activate the virtual environment with the above command every time you open a newshell to run, install or update Red. You can check out other commands like pyenvlocal andpyenvglobal if you wish to keep the virtualenv activated all the time.

Continue by Installing Red.

Installing Red¶

Choose one of the following commands to install Red.

To install without additional config backend support:

Or, to install with PostgreSQL support:

Note

These commands are also used for updating Red

Setting Up and Running Red¶

After installation, set up your instance with the following command:

This will set the location where data will be stored, as well as yourstorage backend and the name of the instance (which will be used forrunning the bot).

Once done setting up the instance, run the following command to run Red:

It will walk through the initial setup, asking for your token and a prefix.You can find out how to obtain a token withthis guide.

Tip

If it’s the first time you’re using Red, you should check our Getting started guidethat will walk you through all essential information on how to interact with Red.