If you are interested to learn about the Python Extension Programming with C
What is PIP?
PIP is a package manager for Python packages, or modules if you like. Python pip is the package manager for Python packages. We can use pip to install packages that do not come with Python. The basic syntax of pip commands in command prompt is:
pip 'arguments'
Note: If you have Python version 3.4 or later, PIP is included by default.
What is a Package?
A package contains all the files you need for a module. Modules are Python code libraries you can include in your project.
Check if PIP is Installed
Navigate your command line to the location of Python’s script directory, and type the following:
Example
Check PIP version:C:\Users\<em>Your Name</em>\AppData\Local\Programs\Python\Python36-32\Scripts>pip --version
Install PIP
If you do not have PIP installed, you can download and install it from this page:
How do I run pip in Python?
Ensure you can run pip from the command line
Run python get-pip.py . 2 This will install or upgrade pip. Additionally, it will install setuptools and wheel if they’re not installed already. Be cautious if you’re using a Python install that’s managed by your operating system or another package manager.
Download a Package
Downloading a package is very easy. Open the command line interface and tell PIP to download the package you want. Navigate your command line to the location of Python’s script directory, and type the following:
Example
Download a package named "camelcase":C:\Users\<em>Your Name</em>\AppData\Local\Programs\Python\Python36-32\Scripts>pip install camelcase
Now you have downloaded and installed your first package!
Using a Package
Once the package is installed, it is ready to use. Import the “camelcase” package into your project.
Example
Import and use "camelcase":import camelcase c = camelcase.CamelCase() txt = "hello world" print(c.hump(txt))
Find Packages
Find more packages at
Remove a Package
Use the uninstall
command to remove a package:
Example
Uninstall the package named "camelcase":C:\Users\<em>Your Name</em>\AppData\Local\Programs\Python\Python36-32\Scripts>pip uninstall camelcase. The PIP Package Manager will ask you to confirm that you want to remove the camelcase package:Uninstalling camelcase-02.1:<br> Would remove: <br> c:\users\<em>Your Name</em>\appdata\local\programs\python\python36-32\lib\site-packages\camecase-0.2-py3.6.egg-info<br> c:\users\<em>Your Name</em>\appdata\local\programs\python\python36-32\lib\site-packages\camecase\*<br>Proceed (y/n)?
Press y
and the package will be removed.
List Packages
Use the list
command to list all the packages installed on your system:
Example
List installed packages:C:\Users\Your Name\AppData\Local\Programs\Python\Python36-32\Scripts>pip list
Result:Package ; Version<br>-----------------------<br>camelcase ; 0.2<br>mysql-connector 2.1.6<br>pip& 18.1<br>pymongo&; 3.6.1<br>setuptools; 39.0.1
Upgrading Pip On Windows
Pip is a key tool in the Python ecosystem, and as such is updated on a regular basis. Changes can always be found in the release notes for each version. In order to keep your version of pip up to date, you can run the following on the command line:
python -m pip install -U pip
This command will uninstall the outdated version of pip first, and then download the most current iteration. It’s also possible to downgrade to a previous version of pip, in case a newer version is causing unexpected compatibility errors. For example, to downgrade to pip v18.0 run the following command:
python -m pip install pip==18.0
Next Steps
Try the ActiveState Platform to build Python packages faster and safer. Create a custom Python runtime for your next project. Pick just the packages you need, and we’ll automatically resolve all dependencies, build it (including C code) and package it for your platform.

How ActiveState Can Help
ActiveState provides a unified cross-platform toolchain for modern Python package management. It can replace the complex and hard-to-maintain in-house solutions built from multiple package managers, environment management tools and other solutions.
By adopting the ActiveState Platform, developers can:
- Automated building of packages from source, including link C libraries without the need for a local build environment.
- Automated resolution of dependencies (or suggestions on how to manually resolve conflicts), ensuring that your environment always contains a set of known good dependencies that work together.
- Central management of a single source of truth for your environment that can be deployed with a single command to all development and CI/CD environments, ensuring consistent reproducibility.
- Automated installation of virtual Python environments on Windows or Linux without requiring prior setup.
- The ability to find, fix and automatically rebuild vulnerable environments, thereby enhancing security and dramatically reducing time and effort involved in resolving CVEs.
- Visually seeing which versions of which packages are approved for use, thereby taking the guesswork out of development.
Those that prefer to work from the command line can leverage the ActiveState Platform’s CLI, the State Tool, which acts as a universal package manager for Python, and provides access to most of the features offered by the Platform.
Modern Python Package Management
ActiveState provides a unified cross-platform toolchain for modern Python package management. It can replace the complex and hard-to-maintain in-house solutions built from multiple package managers, environment management tools and other solutions. By adopting the ActiveState Platform, developers can:
- Increase the security of Python environments
- Improve the transparency of your open source supply chain
- Dramatically reduce package and environment management overhead
- Eliminate dependency hell
- Reduce “works on my machine” issues
Ultimately, developers that are willing to adopt the ActiveState Platform will spend less time wrestling with tooling and more time focused on doing what they do best: coding. To try the ActiveState Platform for yourself, sign-up for a free account.
Custom repository[edit]
Besides the default PyPI repository, Pip supports custom repositories as well.[16] Such repositories can be located on an HTTP(s) URL or on a file system location. A custom repository can be specified using the -i or –index-url option, like so:
pip install -i https://your-custom-repo/simple <package name>
Or with a filesystem:
pip install -i /path/to/your/custom-repo/simple <package name>
Basic Package Installation
The install
command used to install packages using pip
. Let’s take an example: Suppose we want to install requests
, a popular HTTP library for Python. We can do it with the help of the following command.
pip install requests
Output
Collecting requests
Using cached
Collecting chardet<3.1.0,>=3.0.2
nstalling collected packages: chardet, urllib3, idna, certifi, requests
Successfully installed certifi-2019.11.28 chardet-3.0.4 idna-2.8 requests-2.22.0 urllib3-1.25.7
Here, we can see that the pip
has been used with the install
command followed by the name of the package we want to install (requests
).
All other dependencies like chardet
, urllib3
and certifi
required for this package are also installed by pip
.
Specifying Package Version
When pip
install
is used in its minimal form, pip
downloads the most recent version of the package. Sometimes, only a specific version is compatible with other programs. So, we can define the version of the package in the following way:
pip install requests==2.21.0
Here, we have installed the 2.11.0 version of the requests
library.
Listing Installed Packages with pip
The pip list
command can be used to list all the available packages in the current Python environment.
pip list
Output
Package Version
---------- ----------
certifi 2019.11.28
chardet 3.0.4
idna 2.8
pip 19.3.1
requests 2.22.0
setuptools 45.0.0
urllib3 1.25.7
wheel 0.33.6