This article will tell you how to install Python and PIP on Windows OS. It will also tell you how to install pip on Windows and how to upgrade pip use python command line. Before installing both of them, you should first go to python download page to get python installer.
1.How To Install PIP On Windows With Python Command-Line.
- If you had installed python on windows and you just want to install pip windows, you can follow the below steps.
- If you do not install python at all, please first read section 2.
- First, you can open a dos window and run the command
python -m ensurepip --default-pipto bootstrap it from the standard python library.
- If you can not run pip after run the above command, you can download the file get-pip.py. Then run command
python get-pip.pyin a dos window. This command will install or upgrade both python setuptools, wheel, and pip.
- You can run command
python -m pip install --upgrade pip setuptools wheelto check whether pip, python setuptools and wheel is up to date or not.
$ python -m pip install --upgrade pip setuptools wheel Collecting pip Downloading pip-20.3.3-py2.py3-none-any.whl (1.5 MB) |████████████████████████████████| 1.5 MB 73 kB/s Collecting setuptools Downloading setuptools-51.3.3-py3-none-any.whl (786 kB) |████████████████████████████████| 786 kB 34 kB/s Collecting wheel Downloading wheel-0.36.2-py2.py3-none-any.whl (35 kB) Installing collected packages: pip, setuptools, wheel Attempting uninstall: pip Found existing installation: pip 20.2.1 Uninstalling pip-20.2.1: Successfully uninstalled pip-20.2.1 Attempting uninstall: setuptools Found existing installation: setuptools 41.4.0 Uninstalling setuptools-41.4.0: Successfully uninstalled setuptools-41.4.0 Attempting uninstall: wheel Found existing installation: wheel 0.33.6 Uninstalling wheel-0.33.6: Successfully uninstalled wheel-0.33.6 Successfully installed pip-20.3.3 setuptools-51.3.3 wheel-0.36.2
- If the above method does not take effect, go to https://pypi.org/project/pip/#files, download the latest pip zip file on page right side.
- Unzip the download file to a local folder, and copy the folder content ( do not copy the folder ) to the python install directory ( for example C:\Python37).
- Open a dos window, goto the python home folder, run the command
python setup.py installto install pip.
- Add pip to PTH environment variable by add
C:\Python2x\Scriptsto the PATH environment variable.
2. How To Install Python 3.7 And PIP.
- Double click the downloaded Python 3.7 installer, then you will see below installation wizard window.
- There are two options that you can choose. Install Now will install python with all default configurations. Customize installation will let you configure most installation settings such as install components and target directory etc.
- No matter which option you choose, you had better check both the two checkbox at the bottom of the wizard dialog, especially Add Python 3.7 to PATH checkbox.
- This checkbox can add the python executable folder to the Windows PATH environment variable values automatically ( After python installation you can find C:\Python37\Scripts\;C:\Python37\ in the windows system PATH environment variable values). Then you can run the python command in a terminal directly after the python installation.
- In this example we choose the second option – Customize installation. Then it will popup Optional Features wizard dialog which will let you choose the installed components, I select all checkbox that contains pip, then it will add pip to PATH environment variable.
- Click Next button to go to Advanced Options wizard dialog. Please select the first five checkboxes at least. The Add Python to environment variables checkbox must be checked, this will add python 3.7 to PATH environment variable. You can also choose the python installation target directory in this dialog ( You had better choose a directory which the directory path does not contain white space and not too long such as C:\Python37).
- Then click Install button, it will install python / pip on windows until you see the installation successful dialog.
3. How To Use Python / PIP On Windows.
3.1 How To Use Python On Windows.
Now the python 3.7 and pip has been installed on windows OS, we need to verify whether it is installed correctly or not.
- Open a dos console window, run
pythoncommand, if you see below output that means python is installed correctly. The exit() method will quit python interactive mode.
C:\Users>python Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD6 4)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> exit()
- If it shows an error message such as command python can not be found, this is because the python path ( C:\Python37 ) is not included in the system PATH environment variable, you should add it in the PATH environment variable manually. You can reinstall python 3.7 and check the Add Python 3.7 to PATH checkbox to resolve the error entirely. Or you can read the article How To Set Windows Environment Variables.
3.2 How To Use PIP On Windows.
PIP is a python script that can manage python packages. It can process search, install, update and uninstall operation to python packages. To find all useful python packages, you can go to https://pypi.org/. In this example, pip is saved in C:\Python37\Scripts directory.
- Open a dos window and run
pip --versioncommand then you can see below output in the console that means pip has been installed correctly.
C:\Users>pip --version pip 10.0.1 from c:\python37\lib\site-packages\pip (python 3.7)
- How to upgrade pip version.
python -m pip install --upgrade pip
- How to downgrade pip version.
python -m pip install pip==18.1
- How to use pip to search install packages.
pip search package-name pip install package-name
- How to get pip command help.
$ pip help Usage: pip <command> [options] Commands: install Install packages. download Download packages. uninstall Uninstall packages. freeze Output installed packages in requirements format. list List installed packages. show Show information about installed packages. check Verify installed packages have compatible dependencies. config Manage local and global configuration. search Search PyPI for packages. cache Inspect and manage pip's wheel cache. wheel Build wheels from your requirements. hash Compute hashes of package archives. completion A helper command used for command completion. debug Show information useful for debugging. help Show help for commands. General Options: -h, --help Show help. --isolated Run pip in an isolated mode, ignoring environment variables and user configuration. -v, --verbose Give more output. Option is additive, and can be used up to 3 times. -V, --version Show version and exit. -q, --quiet Give less output. Option is additive, and can be used up to 3 times (corresponding to WARNING, ERROR, and CRITICAL logging levels). --log <path> Path to a verbose appending log. --no-input Disable prompting for input. --proxy <proxy> Specify a proxy in the form [user:[email protected]]proxy.server:port. --retries <retries> Maximum number of retries each connection should attempt (default 5 times). --timeout <sec> Set the socket timeout (default 15 seconds). --exists-action <action> Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort. --trusted-host <hostname> Mark this host or host:port pair as trusted, even though it does not have valid or any HTTPS. --cert <path> Path to alternate CA bundle. --client-cert <path> Path to SSL client certificate, a single file containing the private key and the certificate in PEM format. --cache-dir <dir> Store the cache data in <dir>. --no-cache-dir Disable the cache. --disable-pip-version-check Don't periodically check PyPI to determine whether a new version of pip is available for download. Implied with --no-index. --no-color Suppress colored output. --no-python-version-warning Silence deprecation warnings for upcoming unsupported Pythons. --use-feature <feature> Enable new functionality, that may be backward incompatible. --use-deprecated <feature> Enable deprecated functionality, that will be removed in the future.