This article may also seem a bit unusual because I covered how to install Python’s PIP in the last article. This article is the second part of that. This is something that seemed like it should be two articles, so it is two articles.
Additionally, I share this information so that I can write future articles. So, by themselves, these two articles won’t accomplish much by themselves. They will come in handy for future reference and that’s the point of this.
In the previous article about how to install Python’s PIP, you learned the basics. In that article, you learned how to install PIP. That’s all well and good, but then you might be confused when you go to install a package installed by PIP.
During the package installation, you may see a warning that looks like this:
1 | Consider adding this directory to PATH |
This is because PIP installs the packages somewhere like your ~/local/.bin directory. If you then try to run the package from the terminal, it won’t be found.
For the record, this is for people using Bash. I’m not sure about other shells.
You can still use PIP packages just fine, you just have to specify the path. That’s a pain in the butt and not something you should have to do. Instead, we’re going to add the path as suggested. If you’ve done that, you can just type the package name into the terminal to run your PIP-installed Python applications.
So, let’s do that…
Install Python’s PIP Part Two:
By now it should be obvious that this requires an open terminal. You did read the first article, right? As such, you can usually open your terminal with your keyboard, simply press
With your terminal open, we need to add some text to your ~/.bashrc file that sets the path. It’s pretty straightforward and we’ll be using Nano for this. Click that link if you’re not sure if you have Nano installed.
Let’s open the file for editing with this command:
1 | nano ~/.bashrc |
Then scroll to the bottom.
At the bottom, add a new line.
Copy and paste the following:
1 2 | # Python PIP Path export PATH=$PATH:/home/$USER/.local/bin |
Next, we save the changes and exit Nano by pressing
No changes will have been made just yet. You could reboot or reload your desktop session if you wanted, but you can tell the shell to reload the file and thus have the changes take effect. To do that, you’d enter this:
1 | source ~/.bashrc |
At that point, you can install PIP packages and have them run when you just type the command into the terminal. There’s no need to add anything else to the command. This sets the path that PIP was complaining about.
And now you’re ready to install Python PIP packages. This is an important step after you install Python’s PIP. It should serve you well, assuming you want Python packages installed in a pretty simple manner.
IMPORTANT: Read Part 1 to install Python’s PIP.
Closure:
As you can tell by the length, there’s a reason that this is a second article. I’ll have to remember to edit the first article when this article gets published. It’s not that it’s complicated, it’s just long.
So, it seemed best to turn this into a second article – especially because it’s not technically a necessary step. You can comfortably run Python packages by using the file path, but this is much easier.
Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.