pip 與 ez_setup 與 easy_install.exe

最後更新: 2019-02-13

目錄

  • pip
  • Check pip installed package version
  • setuptools
  • ez_setup
    - Windows 7 Install ez_setup
    - Ubuntu Install ez_setup
  • egg

pip

 

Install

apt-get install python3-pip       # D11

yum install python-pip             # Centos

Manual Install:

apt-get purge python-pip

# Installing with get-pip.py

wget https://bootstrap.pypa.io/get-pip.py

python get-pip.py

Upgrade pip

pip install --upgrade pip

Cmd:

  • install
  • uninstall
  • search
  • list                        # List installed packages
  • check                    # Verify installed packages have compatible dependencies.

Example:

List Package

pip list

Package    Version
---------- -------
pip        20.3.4
setuptools 28.8.0
wheel      0.29.0

Install selenium

pip install selenium

安装指定版本的包

pip install vncdotool==0.11.2

Upgrade Package

pip install --upgrade vncdotool

一次過安一堆 Package

# -r,--requirement <file>

pip install -r requirements-2.6.txt

#
# requirements known to work with python2.6
#
Pillow==2.6.1
Twisted==14.0.2
wsgiref==0.1.2
zope.interface==4.1.1

 


Check pip installed package version

 

In Code

import pandas as pd
print(pd.__version__)

In Shell

pip list | grep pandas

pandas               1.3.5

 


setuptools

 

Easily download, build, install, upgrade, and uninstall Python packages

Setuptools is a collection of enhancements to the Python distutils that allow developers to more easily build and

distribute Python packages, especially ones that have dependencies on other packages.

 


ez_setup

 

Windows 7 Install ez_setup:

下載:

https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py

OR

https://pypi.python.org/packages/source/s/setuptools/ 下載最新的 source, 比如 "setuptools-5.4.zip"

安裝:

C:\tmp>python ez_setup.py

# 安裝後 ez_setup 會在 "C:\Python27\Scripts", 獲得 easy_install.exe

* 安裝期間會幫手安裝 setuptools

安裝時的 output:

Downloading https://pypi.python.org/packages/source/s/setuptools/setuptools-5.8.zip
Extracting in c:\users\tim\appdata\local\temp\tmpv9harv

............................................

Processing setuptools-5.4-py2.7.egg
Copying setuptools-5.4-py2.7.egg to c:\python27\lib\site-packages
Adding setuptools 5.4 to easy-install.pth file
Installing easy_install-script.py script to C:\Python27\Scripts
Installing easy_install.exe script to C:\Python27\Scripts
Installing easy_install-2.7-script.py script to C:\Python27\Scripts
Installing easy_install-2.7.exe script to C:\Python27\Scripts

Installed c:\python27\lib\site-packages\setuptools-5.4-py2.7.egg
Processing dependencies for setuptools==5.4
Finished processing dependencies for setuptools==5.4

Usage Example: Install selenium Client Driver on linux

https://pypi.python.org/pypi/selenium

C:\Python27\Scripts>easy_install.exe selenium

Searching for selenium
Reading https://pypi.python.org/simple/selenium/
Best match: selenium 2.35.0
Downloading https://pypi.python.org/packages/source/s/selenium/selenium-2.35.0.tar.g...
Processing selenium-2.35.0.tar.gz
Writing c:\users\lwy\appdata\local\temp\easy_install-x1ovvn\selenium-2.35.0\setup.cfg
Running selenium-2.35.0\setup.py -q bdist_egg --dist-dir c:\users\lwy\appdata\local\temp\easy_install-x1ovvn\selenium-2.35.0\egg-dist-tmp-cfxstg
Adding selenium 2.35.0 to easy-install.pth file

Installed c:\python27\lib\site-packages\selenium-2.35.0-py2.7.egg
Processing dependencies for selenium
Finished processing dependencies for selenium

Ubuntu:

Install package:

https://pypi.python.org/pypi/ez_setup 下載 ez_setup-0.9.tar.gz

ez_setup:

root@ubuntu:/root/ez_setup-0.9# python setup.py

# 當系統沒有安裝 setuptools 時, 就會有以下 Error

Traceback (most recent call last):
  File "setup.py", line 1, in <module>
    from setuptools import setup, find_packages
ImportError: No module named setuptools

apt-get install python-setuptools

OR

apt-get install python-setuptools python-dev build-essential

 


egg

 

Easy Install is deprecated. Do not use it. Instead use pip.

PEAK(Python Enterprise Application Kit)

"easy_install" bundled with "setuptools"

Usage:

easy_install somepackage.egg

easy_install http://somehost.somedomain.com/somepackage.egg

dist-packages

In Debian : "Third party Python software installed from Debian packages goes into dist-packages, not site-packages. This is to reduce conflict between the system Python, and any from-source Python build you might install manually. "

 

 


 

Creative Commons license icon Creative Commons license icon