【Python】pip - 安装第三方包的神器

本文介绍了如何使用pip安装Python第三方库。首先,从官方网址下载并安装pip,然后通过命令行运行Python get-pip.py进行安装。在安装过程中可能会遇到环境变量配置问题,需要将pip的安装路径添加到系统路径中。接着,演示了安装numpy和matplotlib等库的过程,以及在Windows和Mac OS上使用pip的示例。
摘要由CSDN通过智能技术生成

使用Python,肯定希望使用大量成熟的第三方包,从而快速用到自己的项目。


还在一个个寻找,手动下载吗?


pip就是这样一个神器,自动搜索、下载和安装第三方包:


1,首先请安装pip自己,下载地址(也可以通过附件下载):

http://www.pip-installer.org/en/latest/installing.html#python-os-support

2,安装pip,在命令行运行Python get-pip.py

3, 增加环境变量:C:/Python27/Scripts(pip安装的路径)(windows经常出此问题,可以通过在cmd输入pip看是否如下回复)


Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.


C:\Documents and Settings\Administrator>python pip install beautifulsoup4
python: can't open file 'pip': [Errno 2] No such file or directory


C:\Documents and Settings\Administrator>pip
'pip' 不是内部或外部命令,也不是可运行的程序
或批处理文件。


C:\Documents and Settings\Administrator>path
PATH=C:\Python27\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Pro
gram Files\Anite\LogViewer;C:\Program Files\Common Files\Sony Shared\FeliCaLibra
ry;C:\Program Files\Common Files\Sony Shared\FeliCaNFCLibrary


C:\Documents and Settings\Administrator>python
Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()


C:\Documents and Settings\Administrator>python "\\vmware-host\Shared Folders\桌
面\get-pip.py" install
Traceback (most recent call last):
  File "\\vmware-host\Shared Folders\桌面\get-pip.py", line 19154, in <module>
    main()
  File "\\vmware-host\Shared Folders\桌面\get-pip.py", line 194, in main
    bootstrap(tmpdir=tmpdir)
  File "\\vmware-host\Shared Folders\桌面\get-pip.py", line 82, in bootstrap
    import pip
  File "c:\docume~1\admini~1\locals~1\temp\tmpbzsjty\pip.zip\pip\__init__.py", l
ine 13, in <module>
  File "c:\docume~1\admini~1\locals~1\temp\tmpbzsjty\pip.zip\pip\utils\__init__.
py", line 27, in <module>
  File "c:\docume~1\admini~1\locals~1\temp\tmpbzsjty\pip.zip\pip\_vendor\pkg_res
ources\__init__.py", line 3130, in <module>
  File "c:\docume~1\admini~1\locals~1\temp\tmpbzsjty\pip.zip\pip\_vendor\pkg_res
ources\__init__.py", line 3116, in _call_aside
  File "c:\docume~1\admini~1\locals~1\temp\tmpbzsjty\pip.zip\pip\_vendor\pkg_res
ources\__init__.py", line 3143, in _initialize_master_working_set
  File "c:\docume~1\admini~1\locals~1\temp\tmpbzsjty\pip.zip\pip\_vendor\pkg_res
ources\__init__.py", line 633, in _build_master
  File "c:\docume~1\admini~1\locals~1\temp\tmpbzsjty\pip.zip\pip\_vendor\pkg_res
ources\__init__.py", line 626, in __init__
  File "c:\docume~1\admini~1\locals~1\temp\tmpbzsjty\pip.zip\pip\_vendor\pkg_res
ources\__init__.py", line 682, in add_entry
  File "c:\docume~1\admini~1\locals~1\temp\tmpbzsjty\pip.zip\pip\_vendor\pkg_res
ources\__init__.py", line 2110, in find_on_path
WindowsError: [Error 234] : '\\\\vmware-host\\shared folders\\\xd7\xc0\xc3\xe6/*
.*'


C:\Documents and Settings\Administrator>python C:\get-pip.py install
Collecting install
c:\docume~1\admini~1\locals~1\temp\tmpjuymjr\pip.zip\pip\_vendor\requests\packag
es\urllib3\util\ssl_.py:315: SNIMissingWarning: An HTTPS request has been made,
but the SNI (Subject Name Indication) extension to TLS is not available on this
platform. This may cause the server to present an incorrect TLS certificate, whi
ch c

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值