Using pip3 to install Python3 modules

To run the following commands, you must log into your server via SSH with your Shell user. View the following articles for more information:

Using pip3

If you've installed a custom version of Python 3, pip3 is already installed. To use it, make sure you've first followed all the instructions in the following article:

Next, run the following to activate your local Python environment.

[server]$ . ~/.bash_profile

You now have access to pip3. Confirm this by running the following:

[server]$ pip3 --version
pip 9.0.1 from /home/username/opt/python-3.6.2/lib/python3.6/site-packages (python 3.6)

Installing custom modules within your virtual environment

When working with Python projects, it's always a good idea to create a virtual environment. This allows you to create an isolated environment, separate from the system version of Python. Any changes you make to this virtual environment only affects the single project, nothing else. In this way, it's a very safe way to test your projects as they can be deleted and rebuilt very easily. View the following article for further details.

Installing a virtualenv is important if you want to run 'pip'. Normally, pip attempts to install in the server's default Python system folder. This does not work since you do not have access to this folder. When you create a virtual environment, pip installs locally under your user, so you'll be able to install anything you like without error.

To use pip3 to easily install custom modules:

  1. Install a custom version of Python3 and create a virtual environment.
  2. Run the following command to activate this new virtual environment (change the directory to where you installed it):
    [server]$ source my_project/bin/activate
    The name of the current virtual environment appears to the left of the prompt. For example:
    (my_project) [server]$ 
  3. Use pip3 to install a module:
    [server]$ pip3 install <module>
    You can use 'python-openstackclient' if you're going to work with openstack. For example:
    [server]$ pip3 install python-openstackclient

View the following links for further module examples:

See also

Did this article answer your questions?

Article last updated .