pip: PyPI Package Manager in python

PIp is python’s most widely used package manager. Installed by default for versions of python. It is similar to the node’s npm, ruby on rails gem if anyone has ever used it.

  1. Install packages
  2. To install the latest version of a package:
pip install somepackage
  1. To install a certain version, use the following syntax:
pip install SomePackage==1.x.x
  1. Or specify the minimum version you want to install:
pip install SomePackage>=1.0.4
  1. If permission denied errors appear, we use the sudo command to install them.
  2. There is a package.json file in the node to save the packages with the version we have installed. And then if the calf goes somewhere else, just use the command
npm install
  1. Is to automatically install everything in the package.json file. Similarly, in python we can create requirements.txt file. This file is similar to package.json file. Use pip to install via requirements.txt file:
pip install -r requirements.txt
  1. To create requirements.txt file we do:
pip freeze > requirements.txt 
  1. Create requirements.txt in the current virtualenv:
pip freeze --local > requirements.txt
  1. List all installed packages used pip To list all installed packages (already exists in the requirements.txt file or not):
pip list
  1. List all packages outdate and show the latest versions of those packages.
pip list --outdated
  1. Above are the packages I installed in my own computer.
  2. Upgrade packages
  3. To update the package:
pip install --upgrade SomePackage
  1. Sometimes we will get a notification that pipour version is not the latest version.
pip install --upgrade pip
  1. This command will upgrade pipto the latest current version (It looks like it is currently 19.0.3). We can see the version ofpip
pip -V
pip --version
  1. Uninstall Packages
pip uninstall SomePackage
  1. Use a certain version of python with pip
  2. If your system uses both python2 and python3 and the default is python2. Usually when used:
pip install [package]
  1. It will understand you are using to install on for python2. It is similar to the command:
pip2 install [package]
  1. If you want to install it on python3:
pip3 install [package]
  1. You can also set your python default to be python 3. That’s it
pip install [package]
  1. will install by default on python3.
  2. Recommend:
  3. If you use multiple versions of python, it is best to use virtuarlenv. It will separate the versions of python and the installation packages for each version.
  4. Conclusion
  5. Above is an introduction to pip. What probably needs to know when starting with python. Hope the article will be useful to you. Thanks for reading.

#python #programming

pip: PyPI Package Manager in python
3.50 GEEK