python26pip
⑴ windows下如何安装pip
方法如下:
1、pip是依赖python的,首先检查下windows机器上有没有安装python,或者有没有添加到环境变量中,如果都没有需要安装或者加入环境变量
(1)python26pip扩展阅读:
pip 是一个现代的,通用的 Python 包管理工具。提供了对 Python 包的查找、下载、安装、卸载的功能。
indows 10是Windows 8.1的下一代操作系统。Windows 8.1的发布并未能满足用户对于新一代主流Windows系统的期待。代号为“Windows Threshold”的Windows10于2014年10月2日发布技术预览版。 于2015年7月29日发行正式版。
新特性
全设备平台制霸,Win10将实现大一统壮举
从4英寸屏幕的“迷你”手机到80英寸的巨屏电脑,都将统一采用Windows 10这个名称。这些设备将会拥有类似的功能,微软正在从小功能到云端整体构建这一统一平台,跨平台共享的通用技术也在开发中。
目前的Windows10预览版主要为台式机和笔记本打造,Windows Insider Program也会登陆。与此同时,Windows 10手机版的名称敲定:Windows10 Mobile,从此再无Windows Phone。
高效的多桌面、多任务、多窗口
分屏多窗口功能增强,现在你可以在屏幕中同时摆放四个窗口,Win10还会在单独窗口内显示正在运行的其他应用程序。同时,Win10还会智能给出分屏建议。
多桌面,现在你可以根据不同的目的和需要来创建多个虚拟桌面,切换也十分方便。点击加号即可添加一个新的虚拟桌面。
资料链接:网络 PIP网络 windows
⑵ python 第三方库怎么安装
【方法一】: 通过setuptools来安装python模块
首先下载
NOTE: 最好下载个setuptools,本人是15.2版本,里面包含了ez_setup
运行 python ez_setup.py
D:\work\installation\setuptools-15.2\setuptools-15.2>python ez_setup.py > 1.txt
Extracting in c:\users\admini~1\appdata\local\temp\tmpbxikxf
Now working in c:\users\admini~1\appdata\local\temp\tmpbxikxf\setuptools-15.2
Installing Setuptools
......
Copying setuptools-15.2-py2.7.egg to c:\python27\lib\site-packages
setuptools 15.2 is already the active version in easy-install.pth
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-15.2-py2.7.egg
Processing dependencies for setuptools==15.2
Finished processing dependencies for setuptools==15.2
运行 easy_install py
D:\work>easy_install py #py 为第三方库文件
Searching for py
Best match: py 1.4.26
Adding py 1.4.26 to easy-install.pth file
Using c:\python27\lib\site-packages
Processing dependencies for py
Finished processing dependencies for py
【方法二】: 通过pip来安装python模块
安装 easy_install pip
D:\work>easy_install pip
Searching for pip
Best match: pip 6.1.1
Processing pip-6.1.1-py2.7.egg
pip 6.1.1 is already the active version in easy-install.pth
Installing pip-script.py script to C:\Python27\Scripts
Installing pip.exe script to C:\Python27\Scripts
Installing pip2.7-script.py script to C:\Python27\Scripts
Installing pip2.7.exe script to C:\Python27\Scripts
Installing pip2-script.py script to C:\Python27\Scripts
Installing pip2.exe script to C:\Python27\Scripts
Using c:\python27\lib\site-packages\pip-6.1.1-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip
运行 pip install xlrd
Usage:
pip <command> [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.
wheel Build wheels from your requirements.
zip DEPRECATED. Zip indivial packages.
unzip DEPRECATED. Unzip indivial packages.
help Show help for commands.
General Options:
-h, --help Show help.
--isolated Run 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.
--log <path> Path to a verbose appending log.
--proxy <proxy> Specify a proxy in the form
[user:passwd@]proxy.server:port.
--retries <retries> Maximum number of retries each connection should
attempt (default 5 times).
--timeout <sec> Set the socket timeout (default 15 seconds).
--exists-action <action> Default action when a path already exists:
(s)witch, (i)gnore, (w)ipe, (b)ackup.
--trusted-host <hostname> Mark this host as trusted, even though it does
not have valid or any HTTPS.
--cert <path> Path to alternate CA bundle.
--client-cert <path> Path to SSL client certificate, a single file
containing the private key and the certificate
in PEM format.
--cache-dir <dir> Store the cache data in <dir>.
--no-cache-dir Disable 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.
【方法三】:直接从网上下载下可执行文件来安装.
比如说,去 >>> pythonlibs <<< 网站,提供了很多Python非官方包下载,二进制文件,下载安装方便.
⑶ 如何在python控制台中使用pip安装本地包
安装Python包,的确是pip最为方便了,简单快捷,因为它直接是从pypi上面下载文件,保证文件的安全性和可靠性,并且资源丰富;
下面是安装步骤:
下载 setuptools,注意对应 Python 的版本,完成后运行 exe 即可完成安装
setuptools-1.4.1.win32-py2.6.exe
下载 pip
pip-1.4.1.tar.gz
安装 pip
5.1 解压pip-1.4.1.tar.gz
5.2 运行CMD,进入命令行
5.3 用CD命令进入 pip 解压目录
5.4 输入 "python setup.py install"
5.5 添加环境变量 path = C:\Python26\ArcGIS10.0\Scripts
验证是否安装成功,运行CMD,进入命令行,输入pip;
如果出现pip的用法介绍,说明安装成功。
进入命令行,输入 "pip install package",package为安装包名称,就可以随意使用了。
⑷ 如何在win7下安装Python及配置
1、首先,从网络搜索python官网下载适合自己电脑python版本。
⑸ python在win10环境下怎样安装wxpython
Python 与 wxPython 运行环境安装
分 别安装python-2.6.2.msi、wxPython2.8-win32-unicode-2.8.10.1-py26.exe
wxPython2.8-win32-docs-demos-2.8.10.1.exe 和py2exe-0.6.9.win32-py2.6.exe
python安装路径采用默认C:/Python26,安装完毕后,将这个目录添 加到path环境变量中
Pydev开发环境安装
如 果未安装jre,请到www.java.com下 载安装
解压缩eclipse-SDK-3.3.2-win32.zip 至D:/eclipse-3.3.2
解压缩 org.python.pydev.feature-1.4.7.2843.zip 至D:/eclipse-3.3.2/pydev-1.4.7/eclipse
在D:/eclipse-3.3.2/eclipse 下创建一个文件夹“links”并在文件夹下创建文件pydev-1.4.7.link
用记事本打开pydev-1.4.7.link ,输入:path=D:/eclipse-3.3.2/pydev-1.4.7
解压后的目录结构如下:
目录结构代码
D:/
+eclipse-3.3.2
|--+eclipse
||--+configuration
||--+features
||--+links
||--+plugins
||--+readme
||---eclipse.exe
|
|--+pydev-1.4.7
|--+eclipse
|--+features
|--+plugins
importwx
if__name__=='__main__':
app=wx.PySimpleApp()
frame=wx.Frame(parent=None)
frame.Show(True)
app.MainLoop()
importwx
if__name__=='__main__':
app=wx.PySimpleApp()
frame=wx.Frame(parent=None)
frame.Show(True)
app.MainLoop()
fromdistutils.coreimportsetup
importpy2exe
setup(windows=[{"script":"app1.py"}])
fromdistutils.coreimportsetup
importpy2exe
setup(windows=[{"script":"app1.py"}])
运行并配置Pydev
双 击D:/eclipse-3.3.2/eclipse/eclipse.exe运行eclipse,选择一个workspace,待加载完毕后,
打 开菜单:Window >> Preferences…,在弹出的对话框中,进入Pydev >> Interpreter – Python,
点击Auto Config会自动加载Python 运行环境配置
开发wxPython应用
新 建一个Pydev Project:proj1,然后新建一个Pydev Mole:app1.py,输入代码:
Python代码
[python]view plain
右击app1.py,选择debug as >> python run, 即可运行
把python脚本转化成exe
新 建模块:convert2exe.py,输入代码:
Python代码
[python]view plain
然后运行windows的dos 命令行,切换目录到proj1/src目录下,输入命令:
python convert2exe.py py2exe
Python 会生成dist文件夹,并把依赖dll 等资源拷贝到这个目录,同时生成 app1.exe
双击 app1.exe 即可运行
⑹ 如何优雅地使用python采集阿里巴巴百万商户信息
Sublime是一款轻量文本编辑工具,可以用来快速编写python脚本,这里就不多作介绍,详情自己网络。本期所需的工具包是selenium,用户需要自行安装,可以通过pip命令快速安装selenium,如下:
因为本人先前已经成功安装selenium,所以这里提示“已经安装成功”,当然要使用pip命令,必须提前安装pip,自行网络,用户安装完上面的所有工具后我们就可以开始本期的装逼之旅了。
第一步、查看www.1688.com网页,确定抓取范围。我们打开阿里巴巴采购首页,我们发现阿里巴巴提供了厂商的搜索接口,如下所示:
第二步、我们试着搜索“化工”,查看得到的结果,如下:
第三步、我们可以看到,我们要的基本信息都存在了,但是联系方式没有,我们任意打开一个厂商的页面,可以看到“联系”这个导航栏项目,点击联系,就可以看到厂商的联系方式,我们在将注意力放到网址url上,我们可以看到,联系这个页面的URL呈现规律性,如www.xxx.1688.com/page/contactinfo.htm,并且联系电话的位置是最前的,这极大地方便了我们采集我们想要的信息,如下:
第四步、啰嗦了那么多,直接开始我们的代码:
首先使用python的selenium包打开一个Firefox浏览器窗口:
1
2
3
4
5
6
7
8
9
#! /usr/bin/env python
#coding:utf-8
from selenium import webdriver
import sys
# 解决中文报错的问题
reload(sys)
sys.setdefaultencoding('utf-8')
driver = webdriver.Firefox()
以上程序就可以打开Firefox浏览器窗口,并且打开的浏览器窗口对象为driver,接下来我们模拟登录,找到阿里巴巴模拟登录的地址为,我们通这个地址模拟登录,并通过selenium的find_element_by_name方法获取网页中的DOM节点,有学过JavaScript的同学应该就会了解DOM节点,具体的代码如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
url = '
k.635.1998096057.d1'
loginUrl = 't=true&redirect_url=
3Dlogin_target_is_blank_1688%26tracelog%3Dmember_signout_signin_s_reg'
driver = webdriver.Firefox()
time.sleep(3)
driver.get(loginUrl)
time.sleep(5)
driver.find_element_by_name("TPL_username").send_keys('这里是你的淘宝账号')
driver.find_element_by_name("TPL_password").send_keys('这里是你的淘宝密码')
driver.find_element_by_name("TPL_password").send_keys(Keys.ENTER)
time.sleep(5)
driver.get(url)
模拟登录成功后我们让页面自动跳转到我们刚才搜索“化工”厂商的那个页面,其中使用了time包里的sleep函数,是为了防止在网速较差的时候,网页加载速度较慢,源码还未下载完毕就执行查找节点的命令导致程序运行失败。接下来我们要做的是查找厂商的主页并找到其联系方式,并且发现厂商找到的结果共有100页,在这里,为了使用方便,我们直接使用for循环来模拟点击下一页进行采集。具体的所有源代码如下所示:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#! /usr/bin/env python
#coding:utf-8
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
import time
import urllib
import urllib2
import sys
import os
import re
import csv
import numpy as np
# 解决中文报错的问题
reload(sys)
sys.setdefaultencoding('utf-8')
csvfile = file('data.csv', 'wb')
writer = csv.writer(csvfile)
writer.writerow((u'企业名称'.encode('gbk'), u'主页'.encode('gbk'), u'产品'.encode('gbk')
, u'联系人'.encode('gbk'), u'电话'.encode('gbk'), u'地址'.encode('gbk')))
url = '
635.1998096057.d1'
loginUrl = '
full_redirect=true&redirect_url=
_is_blank_1688%26tracelog%3Dmember_signout_signin_s_reg'
driver = webdriver.Firefox()
time.sleep(3)
driver.get(loginUrl)
time.sleep(5)
driver.find_element_by_name("TPL_username").send_keys('这里输入你的淘宝账号')
driver.find_element_by_name("TPL_password").send_keys('这里输入你的淘宝密码')
driver.find_element_by_name("TPL_password").send_keys(Keys.ENTER)
time.sleep(5)
driver.get(url)
time.sleep(15)
user_agents = [
'Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.
0.0.11',
'Opera/9.25 (Windows NT 5.1; U; en)',
'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR
2.0.50727)',
'Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.5 (like Gecko) (Kubuntu)',
'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.12) Gecko/20070731 Ubuntu/dapper-se
curity Firefox/1.5.0.12',
'Lynx/2.8.5rel.1 libwww-FM/2.14 SSL-MM/1.4.1 GNUTLS/1.2.9',
"Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.7 (KHTML, like Gecko) Ubuntu/11.04 Chr
omium/16.0.912.77 Chrome/16.0.912.77 Safari/535.7",
"Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:10.0) Gecko/20100101 Firefox/10.0 ",
]
for page in xrange(1, 100):
try:
title = driver.find_elements_by_css_selector("a[class=list-item-title-text]")
proct = driver.find_elements_by_xpath("//div[@class=\"list-item-detail\"]/div[1]
/div[1]/a[1]")
print len(title)
pattern = re.compile('<div class="contcat-desc".*?>(.*?)</div>', re.S)
telPattern = re.compile('<dd>(.*?)</dd>', re.S)
membernamePattern = re.compile('<a.*?class="membername".*?>(.*?)</a>', re.S)
addressPattern = re.compile('"address">(.*?)</dd>', re.S)
for i in xrange(len(title)):
titleValue = title[i].get_attribute('title')
hrefValue = title[i].get_attribute('href') + 'page/contactinfo.htm'
proctValue = proct[i].text
agent = np.random.choice(user_agents)
headers = {'User-Agent' : agent, 'Accept' : '*/*', 'Referer' : ''}
request = urllib2.Request(hrefValue, headers=headers)
response = urllib2.urlopen(request)
html = response.read()
info = re.findall(pattern, html)
try:
info = info[0]
except Exception, e:
continue
tel = re.findall(telPattern, info)
try:
tel = tel[0]
tel = tel.strip()
tel = tel.replace(' ', '-')
except Exception, e:
continue
membername = re.findall(membernamePattern, html)
try:
membername = membername[0]
membername = membername.strip()
except Exception, e:
continue
address = re.findall(addressPattern, html)
try:
address = address[0]
address = address.strip()
except Exception, e:
address = ''
print 'tel:' + tel
print 'membername:' + membername
data = (titleValue.encode('gbk', 'ignore'), title[i].get_attribute('href'), pr
octValue.encode('gbk', 'ignore'), membername, tel, address)
writer.writerow(data)
for t in title:
print t.get_attribute('title')
print t.get_attribute('href') + 'page/contactinfo.htm'
print len(proct)
for p in proct:
a = repr(p.text)
a = a.encode('gbk', 'ignore')
print a
print '#' * 50
js = 'var q=document.documentElement.scrollTop=30000'
driver.execute_script(js)
time.sleep(2)
page = driver.find_elements_by_css_selector("a[class=page-next]")
page = page[0]
page.click()
time.sleep(10)
except Exception, e:
print 'error'
continue
csvfile.close()
driver.close()