Python PIP
What is PIP?
PIP is a package manager for Python packages, or modules if you like.
Note: If you have Python version 3.4 or later, PIP is included by default.
Modules are Python code libraries you can include in your project.
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\Your Name\AppData\Local\Programs\Python\Python36-32\Scripts>pip --version
Installing PIP On Windows
Step 1: Download PIP get-pip.py
Before installing PIP, download the get-pip.py file: get-pip.py on pypa.io.
Download the file to the desired folder in Windows. You can save the file to any location, but remember the path so you can use it later.
Download the file to the desired folder in Windows. You can save the file to any location, but remember the path so you can use it later.
Step 2: Launch Windows Command Line
PIP is a command-line program. When you install PIP, the PIP command is added to your system.
To launch the Command Prompt window:
Both options open the Command Prompt window. However, note that you may need to run the Command Prompt “As Administrator.” If you get an error at any point stating that you don’t have the necessary permissions to perform a task, you will need to open the app as admin.
To run the Command Prompt window “As Administrator,” right-click “Command Prompt” and then select the “Run as…” option.
To launch the Command Prompt window:
- Press Windows Key + X.
- Click Run.
- Type in cmd.exe and hit enter.
Both options open the Command Prompt window. However, note that you may need to run the Command Prompt “As Administrator.” If you get an error at any point stating that you don’t have the necessary permissions to perform a task, you will need to open the app as admin.
To run the Command Prompt window “As Administrator,” right-click “Command Prompt” and then select the “Run as…” option.
Step 3: Installing PIP on Windows
Open the Command Prompt if it isn’t already open. Use the
To install PIP type in the following:
You can view the contents of your current directory using the following command:
cd
command followed by a folder name to navigate to the location of the get-pip.py file. This is the folder you previously used as the download location.To install PIP type in the following:
python get-pip.py
PIP installation should start. If the file isn’t found, double-check the path to the folder where you saved the file.You can view the contents of your current directory using the following command:
dir
The dir
command returns a full listing of the contents of a directory.Step 4: How to Check PIP Version
To check the current version of PIP, type the following command:
pip --version
This command returns the current version of the platform.
Outlet Servers Starting at Only $30.00/mo
Step 5: Verify Installation
Once you’ve installed PIP, you can test whether the installation has been successful by typing the following:
pip help
If PIP has been installed, the program runs, and you should see:pip 18.0 from c:\users\administrator\appdata\local\programs\python\python37\lib\site-packages\pip (python 3.7)
If you receive an error, repeat the installation process.Step 6: Configuration
In Windows, the PIP configuration file is
There is also a legacy per-user configuration file. The file is located at
You can set a custom path location for this config file using the environment variable
%HOME%\pip\pip.ini.
There is also a legacy per-user configuration file. The file is located at
%APPDATA%\pip\pip.ini
.You can set a custom path location for this config file using the environment variable
PIP_CONFIG_FILE
.Upgrading PIP for Python on Windows
New
versions of PIP are released occasionally. These versions may improve
the functionality or be obligatory for security purposes.
You can upgrade PIP on Windows using the Command Prompt window.
To upgrade PIP on Windows, enter the following in the command prompt:
You can upgrade PIP on Windows using the Command Prompt window.
To upgrade PIP on Windows, enter the following in the command prompt:
python -m pip install --upgrade pip
This command first uninstalls the old version of PIP and then installs the most current version of PIP.Downgrade PIP Version
This may be necessary if a new version of PIP starts performing undesirably.
If you want to downgrade PIP to a prior version, you can do so by specifying the version.
To downgrade PIP, enter:
If you want to downgrade PIP to a prior version, you can do so by specifying the version.
To downgrade PIP, enter:
python -m pip install pip==18.1
You should now see the version of PIP that you specified.
Conclusion
Congratulations, you have installed PIP for Python on Windows
.
Now that you have PIP up and running, you are ready to manage your Python packages.
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:
Now you have downloaded and installed your first package!
Import the "camelcase" package into your project.
.
Now that you have PIP up and running, you are ready to manage your Python packages.
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\Your Name\AppData\Local\Programs\Python\Python36-32\Scripts>pip
install camelcase
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))
Remove a Package
Use theuninstall
command to remove a package:Example
Uninstall the package named "camelcase":
C:\Users\Your Name\AppData\Local\Programs\Python\Python36-32\Scripts>pip
uninstall camelcase
Uninstalling camelcase-02.1:
Would remove:
c:\users\Your Name\appdata\local\programs\python\python36-32\lib\site-packages\camecase-0.2-py3.6.egg-info
c:\users\Your Name\appdata\local\programs\python\python36-32\lib\site-packages\camecase\*
Proceed (y/n)?
y
and the package will be removed.List Packages
Use thelist
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
-----------------------
camelcase 0.2
mysql-connector 2.1.6
pip
18.1
pymongo 3.6.1
setuptools 39.0.1
No comments:
Post a Comment
Your feedback is highly appreciated and will help us to improve our content.