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 18.1 from /home/username/my_project/lib/python3.6/site-packages/pip (python 3.6)
At this point it's a good idea to upgrade pip3.
[server]$ python3 -m pip install --upgrade pip Collecting pip Downloading https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl (1.3MB) 100% |████████████████████████████████| 1.3MB 613kB/s Installing collected packages: pip Found existing installation: pip 9.0.1 Uninstalling pip-9.0.1: Successfully uninstalled pip-9.0.1 Successfully installed pip-18.1
[server]$ pip3 --version pip 18.1 from /home/username/opt/python-3.6.2/lib/python3.6/site-packages/pip (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:
- Install a custom version of Python3 and create a virtual environment.
- Run the following command to activate this new virtual environment (change the directory to where you installed it):
[server]$ source my_project/bin/activate
- Use pip3 to install a module:
[server]$ pip3 install <module>
[server]$ pip3 install python-openstackclient
View the following links for further module examples: