
views
This guide assumes the reader knows elementary Python programming and has some familiarity with the command shell on their Windows system (CMD, PowerShell, etc.).
If Python is Not Installed
Go to python.org to select the version of Python you wish to download. Typically, the latest version is preferable as it is less bug-prone and has more features, but nearly all the Python 3.X installations should work just fine. Remember to get the 32-bit or 64-bit depending on your system.
Run the installer once it’s finished downloading. This is to initiate the installation process. For the most part this is self-explanatory, but there’s a crucial check to make.
Check off 'Add Python 3.x to PATH'. This will allow you to use Python and pip from a command shell easily, which is important for installing packages.
If Python is Already Installed
Test to see if pip can be used from the command line already by typing pip -V into a command shell. If this command works and version details for your pip installation are shown, you can skip to Part 2 of this guide. Continue below if the command fails.
Locate the directory in which you installed Python originally. To locate the installation path, press "Window + s" key together and then type Python if you are on Windows 7+. Remember this path; that’s the folder where the executables are for running Python and pip. This may be difficult to find, but typical locations that you may find Python installed at are:
C:\PythonXX
C:\Users\
Open the Environment Variables dialog. This can be done by searching up "system variables" and clicking on the first option, then clicking on the Environment Variables… button.
Add the Python path you just copied to the user 'Path' variable. You can do this by selecting the 'Path' variable, clicking Edit… → New and pasting the path. Paste it again in a new field with "\Scripts" at the end of it. You may need to restart your computer after this step. After following these steps, you will have a local Python installation with full pip functionality that you can use from a command shell.
Finding and Installing Modules for Python
Research what kind of modules you want to install on your computer. There are many, many modules out there that all do great things. In order to deal with the problems you want your program to solve, try looking up modules online by searching "how to
Look up the package name for the module you want to install. Go to pypi.org and look up the module you want. The name of the package that contains it as well as the command needed to install it are at the top of the page. It will look something like pip install
Open the command shell on your computer and run the command from the PyPI page. This will initiate the installation process. Remember to close all instances of Python that are running when you do this.
Using Newly Installed Modules in Python Code
Open a fresh Python instance (IDLE or shell) and type in the import statement for your module. More often than not, the module name for importing is the same as the package name. You can always use the documentation to verify this. Once you type in the line of code to set up your import, you’re good to go. Add some other code as you need to.
Execute your code in your editing environment. If no errors occur, congratulations! You’ve managed to install a brand-new third-party Python module. With this, your foray into Python module installation and usage is complete!
Comments
0 comment