r/programminghelp • u/PlatypusVenom0 • Nov 15 '18
When installing Python packages, what is "pip" and how do you use it?
Note: I went to r/explainlikeimfive first because I need that kind of answer, but the bot redirected me here since it's about programming. Please do not assume I know anything other than what I say I know. Thank you.
I was self-taught Python and generally have a good feel for how to use the language itself. However, whenever I want to install a package, I have no idea how to do it. The tutorials jump straight into typing commands into the command prompt, which I have absolutely no idea how to use, including switching directories. I've looked up tutorials for the tutorials, but they still go over my head. If I want to install package X, how do I get it, and how do I use pip to install it (pretending I've never heard of command prompt)?
I currently have Python 3.4 on Windows 10.
2
u/07734willy Nov 15 '18
To start command prompt, press:
[WindowsKey]+[R], typecmd, and press enter. You'll see a line like-This is the path to the current directory your command prompt is "looking at". That is, the
07734willysubfolder of theUsersfolder on yourCdrive. You can change this directory with the commandcd. Such ascd some_folder. You'll then be in:You can use
..as a shorthand for the parent folder (to go up one directory). You can also usedirto list all the files and folders in the current folder.Now, with that out of the way,
pipis package manager for python. That means you can use pip to install or uninstall modules for import in python. You can usepip -horpip --helpto get a list of commands and switches, which are command line options/parameters you can pass to change the action of the command. For example, we passed the-hswitch to tell pip to print the help screen (which is a common switch that most major command line programs will likely have).You can use
pip install <some_package_name>to install that package for use in your python environment. You can also usepip uninstall <name>to uninstall it. Often, programmers will create a virtual environment for this, so that they can have multiple configurations of python with different (possibly conflicting) modules installed on each, and can freely switch between them. That's a bit more involved, but this should at least give you a start into using the command line and installing packages with pip.