pythonpip,python pip_Python PIP

 2023-11-19 阅读 31 评论 0

摘要:python pippythonpip,In this tutorial, we are going to learn about Python PIP installation and how to use pip in python. In our previous tutorial, we learned about Python Daemon Thread. 在本教程中,我們將學習Python PIP的安裝以及如何在python中使用pip

python pip

pythonpip,In this tutorial, we are going to learn about Python PIP installation and how to use pip in python. In our previous tutorial, we learned about Python Daemon Thread.

在本教程中,我們將學習Python PIP的安裝以及如何在python中使用pip。 在上一教程中,我們了解了Python Daemon Thread 。

Python點 (Python pip)

python anaconda、Python PIP is a package manger, you can use it to install certain libraries to your python installation. You can say it is a replacement for easy_install. We can use pip to install python modules and their dependency also.

Python PIP是一個軟件包管理器,您可以使用它來將某些庫安裝到python安裝中。 您可以說它是easy_install的替代品。 我們可以使用pip安裝python模塊及其依賴項。

In more simple way if we can elaborate PIP in one statement then, Pip is a package management system used to install and manage software packages written in Python. You can download PIP installation file from this link.

如果可以在一個語句中詳細說明PIP,則Pip是一個軟件包管理系統,用于安裝和管理以Python編寫的軟件包。 您可以從此鏈接下載PIP安裝文件。

問題:Python 2.x和Python 3.x:我已經有PIP嗎? (Question: Python 2.x Vs Python 3.x :Do I have already PIP?)

PIP is there if you are on Python 2 >=2.7.9 or Python 3 >=3.4 binaries downloaded from python.org, but you’ll need to upgrade pip. Also, pip will be there if you are working in a Virtual Environment created by virtualenv or pyvenv.

如果您使用的是從python.org下載的Python 2> = 2.7.9Python 3> = 3.4二進制文件,則可以使用PIP,但是您需要升級pip。 另外,如果您在由virtualenv或pyvenv創建的虛擬環境中工作,pip將會存在。

Python安裝點 (Python Install pip)

There are many ways to install pip, but my preferred method is the following:

有多種安裝pip的方法,但我的首選方法如下:

Download the get-pip.py in your system or copy content of the above url in a text file and rename it to get-pip.py.

在系統中下載get-pip.py或將上述url的內容復制到文本文件中,并將其重命名為get-pip.py

Open a CMD window and select the folder location where the file is located. Run python get-pip.py
For verification of a successful installation, open a CMD window and navigate to scripts folder under Python folder (Default is C:\Python27\Scripts). Type command from this location to launch the Python interpreter.

打開CMD窗口,然后選擇文件所在的文件夾位置。 運行python get-pip.py
要驗證安裝是否成功,請打開CMD窗口并導航到Python文件夾下的scripts文件夾(默認為C:\ Python27 \ Scripts)。 從此位置鍵入命令以啟動Python解釋器。

pip freeze

pip freeze

It will show the version number of all modules installed in your Python non-standard library; on a fresh install, if there is any error it will be pop up.

它將顯示您的Python非標準庫中安裝的所有模塊的版本號; 在全新安裝中,如果有任何錯誤,它將彈出。

Microsoft Windows [Version 6.2.9200]
(c) 2012 Microsoft Corporation. All rights reserved.C:\Users\Username>cd c:\Python27\Scripts
c:\Python27\Scripts>pip freezeantiorm==1.1.1
enum34==1.0
requests==2.3.0
virtualenv==1.11.6

設置PIP的環境變量 (Set environment variable for PIP)

If you set PATH environment variable then you won’t have to reference the pip install directory again and again.
Set: (default = C:\Python27\Scripts) in your Windows/Linux “PATH” environment variable.

如果設置PATH環境變量,則不必一次又一次地引用pip安裝目錄。
在Windows / Linux“ PATH”環境變量中設置:(默認= C:\ Python27 \ Scripts)

其他操作系統的PIP安裝 (PIP Installation for other OS)

If you’re running Linux, it’s usually already installed. For other OS follow below steps.

如果您正在運行Linux,則通常已經安裝了它。 對于其他操作系統,請按照以下步驟操作。

  • Ubuntu:
    $ sudo apt-get install python-pip

    Ubuntu:
    $ sudo apt-get install python-pip
  • Fedora:
    $ sudo yum install python-pip

    軟呢帽:
    $ sudo yum install python-pip
  • Mac, you need easy_install:
    $sudo easy_install pip

    Mac,您需要easy_install:
    $sudo easy_install pip

如何使用Pip和PYPI (How to use Pip and PYPI)

PYPI stands for Python Package Index. It’s required for finding a package to install. Packages will be installed from the Python Package Index. PYPI is a repository of software for the Python programming language.

PYPI代表Python軟件包索引。 查找要安裝的軟件包是必需的。 軟件包將從Python軟件包索引中安裝 。 PYPI是Python編程語言的軟件存儲庫。

PIP入門 (Getting Started with PIP)

To install a package using PIP, just open up your terminal, and type in a search query using the PIP tool.

要使用PIP安裝軟件包,只需打開終端,然后使用PIP工具鍵入搜索查詢。

畫中畫命令 (PIP Commands)

Enter pip in your terminal, it will show the following output on screen.

在終端中輸入pip,它將在屏幕上顯示以下輸出。

Usage:pip  [options]Commands:install	Install packages.uninstall     Uninstall packages.freeze        Output installed packages in requirements format.list          List installed packages.show          Show information about installed packages.search        Search PyPI for packages.zip           Zip individual packages.unzip         Unzip individual packages.bundle        Create pybundles.help          Show help for commands.

Commonly used command for pip is install, upgrade or uninstall.

pip常用的命令是安裝,升級或卸載。

PIP搜索包和模塊 (PIP Search packages and modules)

For searching any package, i.e. Flask command will be like below.

對于搜索任何軟件包,即Flask命令將如下所示。

pip search Flask

Following output will be shown with all packages and description.

以下輸出將顯示所有軟件包和說明。

安裝套件 (Installing a package)

If we want to install a required package, let’s say in our case it’s Flask. Now to install it :

如果我們要安裝所需的軟件包,則以Flask為例。 現在安裝它:

pip install Flask

點子–顯示信息 (Pip – Show information)

For checking information about our newly installed packages.

用于檢查有關我們新安裝的軟件包的信息。

pip show Flask
---
Name: Flask
Version: 0.10.1
Location: /usr/local/lib/python2.7/dist-packages
Requires: Werkzeug, Jinja2, itsdangerous

卸載軟件包 (Uninstalling a package)

For uninstalling any package installed by PIP, you can do as below.

要卸載由PIP安裝的任何軟件包,可以執行以下操作。

pip uninstall FlaskUninstalling Flask:
...
.....Proceed (y/n)?Successfully uninstalled Flask

That’s all about python pip installation and it’s usage. To know more, see their official documentation.

這就是關于python pip安裝及其用法的全部內容。 要了解更多信息,請參閱其官方文檔。

翻譯自: https://www.journaldev.com/16160/python-pip

python pip

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/1/183223.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息