python included_python - 安装

本文介绍了在Mac OS环境下,如何使用easy_install和pip安装Python2和Python3的第三方库,如pip、selenium和pymysql,并提供了卸载第三方库的方法。
摘要由CSDN通过智能技术生成

声明:所有操作均是在mac OS 环境下

1.  Python2的第三方库安装

Python2默认没有安装pip工具,但是安装的easy_install,我们可以用easy_install安装pip,在用pip安装其他的第三方库。

bogon:~ evan$ sudo easy_install pip

Searching for pip

Reading https://pypi.python.org/simple/pip/

Best match: pip 9.0.1

Downloading https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5=35f01da33009719497f01a4ba69d63c9

Processing pip-9.0.1.tar.gz

Writing /tmp/easy_install-ilu_ZT/pip-9.0.1/setup.cfg

Running pip-9.0.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-ilu_ZT/pip-9.0.1/egg-dist-tmp-u5uG4o

/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'python_requires'

warnings.warn(msg)

warning: no previously-included files found matching '.coveragerc'

warning: no previously-included files found matching '.mailmap'

warning: no previously-included files found matching '.travis.yml'

warning: no previously-included files found matching '.landscape.yml'

warning: no previously-included files found matching 'pip/_vendor/Makefile'

warning: no previously-included files found matching 'tox.ini'

warning: no previously-included files found matching 'dev-requirements.txt'

warning: no previously-included files found matching 'appveyor.yml'

no previously-included directories found matching '.github'

no previously-included directories found matching '.travis'

no previously-included directories found matching 'docs/_build'

no previously-included directories found matching 'contrib'

no previously-included directories found matching 'tasks'

no previously-included directories found matching 'tests'

creating /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg

Extracting pip-9.0.1-py2.7.egg to /Library/Python/2.7/site-packages

Adding pip 9.0.1 to easy-install.pth file

Installing pip script to /usr/local/bin

Installing pip2.7 script to /usr/local/bin

Installing pip2 script to /usr/local/bin

Installed /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg

Processing dependencies for pip

Finished processing dependencies for pip

或者也可以直接用easy_install下载第三方库。

bogon:~ evan$ sudo easy_install selenium

Password:

Searching for selenium

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

Best match: selenium 3.5.0

Downloading https://pypi.python.org/packages/ac/d7/1928416439d066c60f26c87a8d1b78a8edd64c7d05a0aa917fa97a8ee02d/selenium-3.5.0.tar.gz#md5=986702fdd0e2aec6a4eda134678b8b3f

Processing selenium-3.5.0.tar.gz

Writing /tmp/easy_install-8JkREp/selenium-3.5.0/setup.cfg

Running selenium-3.5.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-8JkREp/selenium-3.5.0/egg-dist-tmp-TSB9ds

warning: no files found matching 'selenium/selenium.py'

warning: no files found matching 'LICENSE'

creating /Library/Python/2.7/site-packages/selenium-3.5.0-py2.7.egg

Extracting selenium-3.5.0-py2.7.egg to /Library/Python/2.7/site-packages

Adding selenium 3.5.0 to easy-install.pth file

Installed /Library/Python/2.7/site-packages/selenium-3.5.0-py2.7.egg

Processing dependencies for selenium

Finished processing dependencies for selenium

bogon:~ evan$

2. python3的第三方库安装:

bogon:~ evan$ which python3

/Library/Frameworks/Python.framework/Versions/3.6/bin/python3

bogon:~ evan$

bogon:~ evan$ which pip3

/usr/bin/which

/Library/Frameworks/Python.framework/Versions/3.6/bin/pip3

bogon:~ evan$ pip3 install pymysql

Collecting pymysql

Downloading PyMySQL-0.7.11-py2.py3-none-any.whl (78kB)

100% |████████████████████████████████| 81kB 42kB/s

Installing collected packages: pymysql

Successfully installed pymysql-0.7.11

bogon:~ evan$ pip3 -help

Usage:

pip [options]

Commands:

install Install packages.

downloadDownload packages.

uninstall Uninstall packages.

freezeOutput installed packages in requirements format.

listList installed packages.

showShow information about installed packages.

check Verify installed packages have compatible dependencies.

searchSearch PyPI for packages.

wheel Build wheels from your requirements.

hashCompute hashes of package archives.

completionA helper command used for command completion.

helpShow help for commands.

General Options:

-h, --helpShow help.

--isolatedRun pip in an isolated mode, ignoring

environment variables and user configuration.

-v, --verbose Give more output. Option is additive, and can be

used up to 3 times.

-V, --version Show version and exit.

-q, --quiet Give less output. Option is additive, and can be

used up to 3 times (corresponding to WARNING,

ERROR, and CRITICAL logging levels).

--log Path to a verbose appending log.

--proxy Specify a proxy in the form

[user:passwd@]proxy.server:port.

--retries Maximum number of retries each connection should

attempt (default 5 times).

--timeout Set the socket timeout (default 15 seconds).

--exists-action Default action when a path already exists:

(s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort.

--trusted-host Mark this host as trusted, even though it does

not have valid or any HTTPS.

--cert Path to alternate CA bundle.

--client-cert Path to SSL client certificate, a single file

containing the private key and the certificate

in PEM format.

--cache-dir

--no-cache-dirDisable the cache.

--disable-pip-version-check

Don't periodically check PyPI to determine

whether a new version of pip is available for

download. Implied with --no-index.

3. 卸载第三方库

pip uninstall pymysql

pip3 uninstall pymysql

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值